This document is archived and information here might be outdated.  Recommended version.


Constructing a high- or low-precision spatial reference (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with spatial references > Constructing a high- or low-precision spatial reference

Constructing a high- or low-precision spatial reference


About constructing a high- or low-precision spatial reference

Each feature dataset or stand-alone feature class in a geodatabase has a coordinate grid. Coordinate values are snapped to the grid when added or edited. The grid's extent is called the x,y domain while the cell spacing is the x,y resolution. Z and measure values also have a spatial domain and resolution values. Before ArcGIS 9.2, geodatabases used a basic or low-precision model. A grid's precision was 1/resolution. At ArcGIS 9.2, a high-precision model was introduced. If you have to work with data that is at ArcGIS 9.1 or earlier, you might need to create a low-precision spatial reference.
For more information on the spatial reference, see Understanding Coordinate Management in the Geodatabase.
The following code example determines whether you are constructing a high- or low-precision spatial reference and sets the default resolution and tolerance values:
[C#]
private void ConstructCoordinateSystem(bool highPrecision)
{
    // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
    Type t=Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
    System.Object obj=Activator.CreateInstance(t);
    ISpatialReferenceFactory3 spatialReferenceFactory=obj as
        ISpatialReferenceFactory3;

    // Create a geographic coordinate system from a .prj file that contains the well-known string.
    // You might need to update the file location.
    ISpatialReference3 spatialReference =
        spatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile(
        "C:\\Program Files\\ArcGIS\\Desktop10.0\\Coordinate Systems\\Geographic Coordinate Systems\\World\\WGS 1984.prj")as ISpatialReference3;

    // Determines whether you are constructing a high- or low-precision spatial reference.
    IControlPrecision2 controlPrecision=spatialReference as IControlPrecision2;
    controlPrecision.IsHighPrecision=highPrecision;

    ISpatialReferenceResolution spatialReferenceResolution=spatialReference as
        ISpatialReferenceResolution;
    ISpatialReferenceTolerance spatialReferenceTolerance=spatialReference as
        ISpatialReferenceTolerance;

    // The following three methods are key: construct horizon, then set the default x,y resolution and tolerance.
    spatialReferenceResolution.ConstructFromHorizon();
    spatialReferenceResolution.SetDefaultXYResolution();
    spatialReferenceTolerance.SetDefaultXYTolerance();

    // Check the x,y spatial domain.
    double xMin;
    double xMax;
    double yMin;
    double yMax;
    spatialReference.GetDomain(out xMin, out xMax, out yMin, out yMax);

    //System.Windows.Forms.MessageBox.Show("Domain : "+ xMin +", "+  xMax + ", "+ yMin +", "+ yMax);
}
[VB.NET]
Private Sub ConstructCoordinateSystem(ByVal highPrecision As Boolean)
    
    ' Set up the SpatialReferenceEnvironment
    ' SpatialReferenceEnvironment is a singleton object and needs to use the Activator class.
    
    Dim t As Type=Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment")
    Dim spatialReferenceFactory As ISpatialReferenceFactory3=CType(Activator.CreateInstance(t), ISpatialReferenceFactory3)
    
    Dim spatialReference As ISpatialReference3=CType(spatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile _
                                                 ("C:\Program Files\ArcGIS\Desktop10.0\Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj"), ISpatialReference3)
    
    ' Determines whether you are constructing a high- or low-precision spatial reference.
    Dim controlPrecision As IControlPrecision2=CType(spatialReference, IControlPrecision2)
    controlPrecision.IsHighPrecision=highPrecision
    
    Dim spatialReferenceResolution As ISpatialReferenceResolution=CType(spatialReference, ISpatialReferenceResolution)
    Dim spatialReferenceTolerance As ISpatialReferenceTolerance=CType(spatialReference, ISpatialReferenceTolerance)
    
    ' The following three methods are key: construct horizon, then set the default x,y resolution and tolerance.
    spatialReferenceResolution.ConstructFromHorizon()
    spatialReferenceResolution.SetDefaultXYResolution()
    spatialReferenceTolerance.SetDefaultXYTolerance()
    
    ' Check the x,y spatial domain.
    Dim xMin As Double
    Dim xMax As Double
    Dim yMin As Double
    Dim yMax As Double
    
    spatialReference.GetDomain(xMin, xMax, yMin, yMax)
    
    'System.Windows.Forms.MessageBox.Show("Domain : " & xMin & ", " & xMax & ", " & yMin & ", " & yMax)
    
End Sub


See Also:

How to import or export a spatial reference




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
Engine Developer Kit Engine