Interface ISpatialReference
Provides access to members that control a SpatialReference.
[Guid("4434D680-F4DA-11D1-BCA6-0000F875BCCE")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ISpatialReference : ISpatialReferenceInfo
Properties
Abbreviation
string Abbreviation { get; }
Property Value
Alias
string Alias { get; }
Property Value
FactoryCode
int FactoryCode { get; }
Property Value
Name
string Name { get; }
Property Value
PrecisionExImpl
An opaque reference to the precision information (including z/m awareness) implementation for this spatial reference.
long PrecisionExImpl { get; }
Property Value
Remarks
This property is for internal use only.
PrecisionImpl
An opaque reference to the precision information implementation for this spatial reference.
long PrecisionImpl { get; }
Property Value
Remarks
This property is for internal use only.
Remarks
string Remarks { get; }
Property Value
SpatialReferenceImpl
SpatialReferenceImpl.
long SpatialReferenceImpl { get; }
Property Value
Remarks
This property is for internal use only.
ZCoordinateUnit
The unit for the Z coordinate.
ILinearUnit ZCoordinateUnit { get; set; }
Property Value
Methods
Changed()
Notify this object that some of its parts have changed (parameter values, z unit, etc.).
void Changed()
GetDomain(out double, out double, out double, out double)
The XY domain extent.
void GetDomain(out double XMin, out double XMax, out double YMin, out double YMax)
Parameters
Remarks
The GetDomain and SetDomain methods are used to set and get the square domain extent of a coordinate system. The domain extent is different than the valid area of a coordinate system. The domain extent is an arbitrary square used to delimit valid coordinates for a spatial reference system and determine their resolution. It is possible that the domain extent is larger than the usable area of a coordinate system (a UTM zone, for example). A small domain extent gives you finer resolution coordinates over a smaller area. A larger domain extent lets you represent features over a larger geographic area but with coarser resolution.
//This code example shows how to get the xy domain extent of a dataset.
private void GetSpatialReferenceProperties(IFeatureClass featureClass)
{
IGeoDataset geoDataset = featureClass as IGeoDataset;
//get access to SpatialReference through IGeoDataset
ISpatialReference spatialReference = geoDataset.SpatialReference;
//get the xy domain extent of the dataset
double xMin;
double xMax;
double yMin;
double yMax;
spatialReference.GetDomain(out xMin, out xMax, out yMin, out yMax);
System.Windows.Forms.MessageBox.Show(xMin + ", " + xMax + ", " + yMin + ", " + yMax);
}
'This code example shows how to get the xy domain extent of a dataset.
'This example assumes that a valid workspace object has already been established.
Sub GetDomain_Example(ByVal pWorkspace As IWorkspace)
Dim pFeatWS As IFeatureWorkspace
pFeatWS = pWorkspace
Dim pFeatDS As IFeatureDataset
pFeatDS = pFeatWS.OpenFeatureDataset("railroad")
Dim pGeoDataset As IGeoDataset
pGeoDataset = pFeatDS
'get access to SpatialReference through IGeoDataset
Dim pSpatRef As ISpatialReference
pSpatRef = pGeoDataset.SpatialReference
Dim dXmax As Double
Dim dYmax As Double
Dim dXmin As Double
Dim dYmin As Double
'get the xy domain extent of the dataset
pSpatRef.GetDomain(dXmin, dXmax, dYmin, dYmax)
Debug.Print(dXmin & ", ", dXmax & ", " & dYmin, ", " & dYmax)
End Sub
GetFalseOriginAndUnits(out double, out double, out double)
Get the false origin and units.
void GetFalseOriginAndUnits(out double falseX, out double falseY, out double xyUnits)
Parameters
Remarks
Use this function to retrieve the following information about the spatial reference of the geometry:
falseX: XMin of the domain.
falseY: YMin of the domain.
XYUnits: Precision of the domain.
//This code example shows how to get the false origin and units
of a dataset
private void GetFalseOriginAndUnits(IFeatureClass featureClass)
{
IGeoDataset geoDataset = featureClass as
IGeoDataset;
//get access to SpatialReference through
IGeoDataset
ISpatialReference spatialReference =
geoDataset.SpatialReference;
//get the false origin and units of the
dataset
double falseX;
double falseY;
double xyUnits;
spatialReference.GetFalseOriginAndUnits(out
falseX, out falseY, out xyUnits);
System.Windows.Forms.MessageBox.Show(falseX + ",
" + falseY + ", " + xyUnits);
}
'This code example shows how to get the false
origin and units of a dataset.
'This example assumes that a valid workspace
object has already 'been established.
Sub GetFalseOriginAndUnits_Example(ByVal
pWorkspace As IWorkspace)
Dim pFeatWS As
IFeatureWorkspace
pFeatWS = pWorkspace
Dim pFeatDS As
IFeatureDataset
pFeatDS =
pFeatWS.OpenFeatureDataset("railroad")
Dim pGeoDataset As
IGeoDataset
pGeoDataset =
pFeatDS
'get access to
SpatialReference through IGeoDataset
Dim pSpatRef As
ISpatialReference
pSpatRef =
pGeoDataset.SpatialReference
'declare variables
that will be used to store the
'false origin and units
of the dataset
Dim dFalseX As
Double
Dim dFalseY As
Double
Dim dXYUnits As
Double
'get the false origin
and units of the dataset
pSpatRef.GetFalseOriginAndUnits(dFalseX, dFalseY, dXYUnits)
Debug.Print(dFalseX
& ", " & dFalseY & ", " & dXYUnits)
End Sub
GetMDomain(out double, out double)
The measure domain extent.
void GetMDomain(out double outMMin, out double outMMax)
Parameters
GetMFalseOriginAndUnits(out double, out double)
Get the measure false origin and units.
void GetMFalseOriginAndUnits(out double falseM, out double mUnits)
Parameters
GetZDomain(out double, out double)
The Z domain extent.
void GetZDomain(out double outZMin, out double outZMax)
Parameters
GetZFalseOriginAndUnits(out double, out double)
Get the Z false origin and units.
void GetZFalseOriginAndUnits(out double falseZ, out double zUnits)
Parameters
HasMPrecision()
Returns true when m-value precision information has been defined.
bool HasMPrecision()
Returns
HasXYPrecision()
Returns true when (x,y) precision information has been defined.
bool HasXYPrecision()
Returns
HasZPrecision()
Returns true when z-value precision information has been defined.
bool HasZPrecision()
Returns
IsPrecisionEqual(ISpatialReference, out bool)
Returns TRUE when the precision information for the two spatial references is the same.
void IsPrecisionEqual(ISpatialReference otherSR, out bool IsPrecisionEqual)
Parameters
otherSRISpatialReferenceIsPrecisionEqualbool
Remarks
The IClone::IsEqual method implementation for spatial references only compares the coordinate system (projection information) portion of the spatial reference. If, in addition, you need to verify that the coordinate grid portions of the spatial references are equal, apply this method after IsEqual. The XY, Z, or M domain and resolution (precision) values, as well as the XY, Z and M cluster tolerances are compared.
SetDomain(double, double, double, double)
The XY domain extent.
void SetDomain(double XMin, double XMax, double YMin, double YMax)
Parameters
Remarks
The xy domain must be square. If you set a wider X or Y extent, it will take precedence. For example, let's say you set these values:
XMin = -180
XMax = 180
YMin = -90
YMax = 90
If you then query the values with GetDomain, you will see that the YMax value is 270. That is because the X extent is 360, so the Y extent must also be 360. The minimum x and y values are always maintained.
When creating a new spatial reference with a projected or geographic coordinate system, the recommended method for defining the XY Domain is ISpatialReferenceResolution::ConstructFromHorizon, followed by ISpatialReferenceResolution::SetDefaultXYResolution and ISpatialReferenceTolerance::SetDefaultXYTolerance. These methods produce a valid domain that covers the valid coordinate range for the coordinate system and reasonable resolution and tolerance values. The default XY tolerance value is 1 mm or its equivalent based on the coordinate system's unit of measure. The default XY resolution value is 0.1 mm or its equivalent. Tolerance values must be at least two times as large as the resolution value.
private void SetSpatialReferenceProperties(IFeatureClass featureClass)
{
IGeoDataset geoDataset = featureClass as IGeoDataset;
//get access to SpatialReference through IGeoDataset
ISpatialReference spatialReference = geoDataset.SpatialReference;
//set the xy domain extent for the dataset
spatialReference.SetDomain(10000, 90000, 10000, 90000);
}
SetFalseOriginAndUnits(double, double, double)
Set the false origin and units.
void SetFalseOriginAndUnits(double falseX, double falseY, double xyUnits)
Parameters
Remarks
When creating a new spatial reference with a projected or geographic coordinate system, the recommended method for defining the XY Domain is ISpatialReferenceResolution::ConstructFromHorizon.
private void SetSpatialReferenceProperties(IFeatureClass featureClass)
{
IGeoDataset geoDataset = featureClass as IGeoDataset;
//get access to SpatialReference through IGeoDataset
ISpatialReference spatialReference = geoDataset.SpatialReference;
//set the false origin and units for the coverage where the
//falseX, falseY, and xyUnits numeric expressions are double
spatialReference.SetFalseOriginAndUnits(475006.096654, 3759312.190404, 124999.999883);
}
SetMDomain(double, double)
The measure domain extent.
void SetMDomain(double inMMin, double inMMax)
Parameters
SetMFalseOriginAndUnits(double, double)
Set the measure false origin and units.
void SetMFalseOriginAndUnits(double falseM, double mUnits)
Parameters
SetZDomain(double, double)
The Z domain extent.
void SetZDomain(double inZMin, double inZMax)
Parameters
SetZFalseOriginAndUnits(double, double)
Set the Z false origin and units.
void SetZFalseOriginAndUnits(double falseZ, double zUnits)