1

I have two layers.

  1. Polygon layer
  2. Polyline layer

Now I want to check if spatial references of these two layers are same. How can I achieve this ??

In spatial reference there are many property like NAME, LINEAR UNIT, FALSE_EASTING, CENTRAL_MERIDIAN etc , and these properties may vary in different projection systems as far as I know.

How can this be done in a better way?

I am using .NET technologies in arcMap

in sample image , some parameters of spatial reference is shown of my polygon layer

1
  • Does any function or method exist like spatialRef.Compare()/Equal() ?? or how can I implement this ??
    – Monir
    Apr 8, 2015 at 5:40

2 Answers 2

2

You can obtain the spatial reference of a feature class using the IGeoDataset Interface:

' Spatial reference of a feature class
Dim geoDataset As IGeoDataset
Set geoDataset = featureLayer.FeatureClass
Set spatialReference = geoDataset.SpatialReference

http://forums.esri.com/Thread.asp?c=159&f=1707&t=223709

OR

'''<summary>Get the spatial reference information of a dataset that is supplied.</summary>
'''  
'''<param name="dataset">An IDataset, this could be a table, feature class, feature dataset, workspace etc.</param>
'''   
'''<returns>An ISpatialReference interface if successful, nothing otherwise.</returns>
'''   
'''<remarks></remarks>
Public Function GetSpatialReferenceFromDataset(ByVal dataset As ESRI.ArcGIS.Geodatabase.IDataset) As ESRI.ArcGIS.Geometry.ISpatialReference

  'If the dataset supports IGeoDataset
  If TypeOf dataset Is ESRI.ArcGIS.Geodatabase.IGeoDataset Then
    'then grab the spatial reference information and return it.
    Dim geoDataset As ESRI.ArcGIS.Geodatabase.IGeoDataset = CType(dataset, ESRI.ArcGIS.Geodatabase.IGeoDataset)

    Return geoDataset.SpatialReference

  Else

    Return Nothing 'otherwise return nothing

  End If

End Function

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Get_Spatial_Reference_from_Dataset_Snippet/00490000003t000000/

1
  • Thanks . But I want to compare spatial references of two layers and take decision that spatial references are same or not ..
    – Monir
    Apr 8, 2015 at 5:22
1

You can do this by going into the catalog and checking the properties window of each feature class under XY Coordinate System. The quickest way would be to compare WKID numbers of each layer.

You can also use the Describe function to identify the spatial reference and compare them. see this for more info on this.

2
  • The question is looking for a .NET solution.
    – artwork21
    Apr 7, 2015 at 13:28
  • oops, my mistake!
    – Lou
    Apr 7, 2015 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.