Provides access to members that control a SpatialReference. Note: the ISpatialReference interface has been superseded by ISpatialReference3. Please consider using the more recent version.
The spatial reference is not defined when creating a new instance of a geometry. It is the developer's responsibility to define a spatial reference that makes sense for the geometry and for the operation. To achieve precise and predictable results using the geometry library, it is essential that the spatial reference of geometries within a workflow is well defined. When performing a spatial operation using two or more geometries, for example an intersection, the coordinate systems of the two geometries must be equal. If the coordinate systems of the geometries are different or undefined, the operation could produce unexpected results.
| Description | ||
|---|---|---|
![]() |
Abbreviation | The abbreviated name of this spatial reference component. |
![]() |
Alias | The alias of this spatial reference component. |
![]() |
Changed | Notify this object that some of its parts have changed (parameter values, z unit, etc.). |
![]() |
FactoryCode | The factory code (WKID) of the spatial reference. |
![]() |
GetDomain | The XY domain extent. |
![]() |
GetFalseOriginAndUnits | Get the false origin and units. |
![]() |
GetMDomain | The measure domain extent. |
![]() |
GetMFalseOriginAndUnits | Get the measure false origin and units. |
![]() |
GetZDomain | The Z domain extent. |
![]() |
GetZFalseOriginAndUnits | Get the Z false origin and units. |
![]() |
HasMPrecision | Returns true when m-value precision information has been defined. |
![]() |
HasXYPrecision | Returns true when (x,y) precision information has been defined. |
![]() |
HasZPrecision | Returns true when z-value precision information has been defined. |
![]() |
IsPrecisionEqual | Returns TRUE when the precision information for the two spatial references is the same. |
![]() |
Name | The name of this spatial reference component. |
![]() |
Remarks | The comment string of this spatial reference component. |
![]() |
SetDomain | The XY domain extent. |
![]() |
SetFalseOriginAndUnits | Set the false origin and units. |
![]() |
SetMDomain | The measure domain extent. |
![]() |
SetMFalseOriginAndUnits | Set the measure false origin and units. |
![]() |
SetZDomain | The Z domain extent. |
![]() |
SetZFalseOriginAndUnits | Set the Z false origin and units. |
![]() |
ZCoordinateUnit | The unit for the Z coordinate. |
| Interfaces | Description |
|---|---|
| ISpatialReferenceInfo | Provides access to members that control the properties common to all components of a spatial reference system. |
| CoClasses and Classes | Description |
|---|---|
| GeographicCoordinateSystem | Creates a geographic coordinate system. |
| ProjectedCoordinateSystem | Creates a projected coordinate system. |
| UnknownCoordinateSystem | Creates an unknown coordinate system. |
The following code demonstrates how to compare two spatial references. There are two ways shown in the example one using IClone and the other using ICompareSpatialReferences and the IsEqualNoVCS method
public static bool CompareSpatialRefs(ISpatialReference sourceSR, ISpatialReference targetSR)
{
IClone sClone = sourceSR as IClone;
IClone tClone = targetSR as IClone;
// first level test compares the coordinate system component
if (!sClone.IsEqual(tClone))
return false;
return true;
}
The following code example demonstrates how to compare two spatial references. It uses the ISpatialReference2 interface to compare the XY precision in addition to the coordinate system. This is the same type of comparison that is performed by the Copy/Paste functionality in ArcCatalog.
Public Function CompareSpatialReferences(ByVal pSourceSR As ISpatialReference, ByVal pTargetSR As ISpatialReference) As Boolean
Dim pSourceClone As IClone
Dim pTargetClone As IClone
Dim bSREqual As Boolean
Set pSourceClone = pSourceSR
Set pTargetClone = pTargetSR
'Compare the coordinate system component of the spatial reference
bSREqual = pSourceClone.IsEqual(pTargetClone)
'If the comparison failed, return false and exit
If Not bSREqual Then
CompareSpatialReferences = False
Exit Function
End If
'We can also compare the XY precision to ensure the spatial references are equal
Dim pSourceSR2 As ISpatialReference2
Dim bXYIsEqual As Boolean
Set pSourceSR2 = pSourceSR
bXYIsEqual = pSourceSR2.IsXYPrecisionEqual(pTargetSR)
'If the comparison failed, return false and exit
If Not bXYIsEqual Then
CompareSpatialReferences = False
Exit Function
End If
CompareSpatialReferences = True
End Function