How can I get current coordinate system type from opened file? I tried var coord = ESRI.ArcGIS.Geometry.esriSRProjCSType.... ???; Can you tell me, what should I do?

UPD: I need to save current map with all layers and geometry into a shapefile. That's why I have to get current coordinate system.


Assuming you have a reference to the feature class pFC:

    ERSI.ArcGIS.Geometry.ISpatialReference pSP = ((ESRI.ArcGIS.GeoDatabase.IGeoDataset)pFC).SpatialReference;

coord now contains the code for the coordinate system. Note that not all projected coordinate systems are defined in esriSRProjCSType, there are more constants defined in esriSRProjCS2Type, esriSRProjCS3Type and esriSRProjCS4Type

However, a little more information in the question would maybe give a better answer.

  • I need something like this: geomDefEdit.SpatialReference_2 = new UnknownCoordinateSystemClass() as ISpatialReference; Where I need current coordinate system instead of "UnknownCoordinateSystemClass()" Nov 19 '14 at 3:38
  • See :help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… for an exaple on how to create a new spatial reference from a esriSRProjCSType. But if you already have the spatial reference (pSP in my answer) you can just copy it
    – Stefan
    Nov 19 '14 at 9:31

You would do something like this:

dataset = "c:/data/landbase.gdb/Wetlands"
spatial_ref = arcpy.Describe(dataset).spatialReference

as per the ESRI help page here

  • He was looking for a c# solution, not python according to the tags.
    – Stefan
    Nov 18 '14 at 12:35
  • Good point! sorry :)
    – Dan_h_b
    Nov 18 '14 at 16:36

Not sure by your question if you want the map spatial reference or a layer. For a map you may use the IMap.SpatialReference Property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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