Using ArcPy, how can I return the name of the projection based on an EPSG code, not a shapefile?

There are many questions/answers out there for doing something similar from a specific shapefile using .Describe(shp), but I haven't been able to get describe to work with an EPSG code.

For example, this:

info = arcpy.SpatialReference(4326).exportToString()
print info

Returns this: GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984', ...

But I just want it to return 'GCS_WGS_1984'

Using arcpy.SpatialReference(4326), returns a class, but I don't know how to unpack/access the info. print(info.__dict__) returns {'_arc_object': <geoprocessing spatial reference object object at 0x02F2B1D0>}. Since it's an object, I tried print arcpy.Describe(info) but that returned an I/O error.

I have read through the SpatialReference Class Documentation but it is still not clear to me how to extract this info (which I think is "projectionName") from an EPSG code rather than a shapefile.

  • 2
    print(arcpy.SpatialReference(4326).name) – Vince Mar 28 at 20:30
  • that worked. I actually tried .Name but didn't think to do it as lowercase. Thank you, I'll accept your answer if you post it below – a11 Mar 28 at 20:37
  • 2
    Python class properties are always case-dependent. – Vince Mar 28 at 20:52

Your Answer

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

Browse other questions tagged or ask your own question.