I am using ArcGIS 10.2.2, Python 2.7. I want to create a spatial reference from the name of a projection, e.g. NAD_1983_BC_Environment_Albers, using the arcpy tool arcpy.CreateSpatialReference_management(). Consider this:

projName = "NAD_1983_BC_Environment_Albers"
#Replace underscores with spaces, works fine.
sr = arcpy.CreateSpatialReference_management(projName.replace('_',' '))

No issues here. Also, I tried the example in the arcpy documentation here:

projName = "NAD 1983 StatePlane California V FIPS 0405 (US Feet)"
sr = arcpy.CreateSpatialReference_management(projName)

This also works fine. So, why does the following generate an error?

projName = "NAD_1983_UTM_Zone_9N"
#Tried both with and without converting underscores to spaces    
sr = arcpy.CreateSpatialReference_management(projName.replace('_',' '))

ERROR 000622: Failed to execute (Create Spatial Reference). Parameters are not valid.
ERROR 000628: Cannot set input into parameter spatial_reference.

Any ideas??

  • Your code worked on my machine arcpy 10.1: >>> import arcpy >>> projName = "NAD_1983_UTM_Zone_9N" >>> sr = arcpy.CreateSpatialReference_management(projName.replace('_', ' ')) >>> print sr PROJCS['NAD_1983_UTM_Zone_9N',GEOGCS .....
    – dassouki
    Nov 27 '14 at 20:53

I am unclear why you prefer the name to the factory code. You can use the srid and there is no fuss with spaces/underscores.

For projected systems: http://resources.arcgis.com/en/help/main/10.2/018z/pdf/projected_coordinate_systems.pdf

For geog. Systems: http://resources.arcgis.com/en/help/main/10.2/018z/pdf/geographic_coordinate_systems.pdf

If you are intent on using the name and converting spaces/underscores,maybe try using your replace statement in the declaration rather than inside the arcpy command. That may be the cause of the second part of the error.


projname = ("name of proj").replace('_',' ')
  • 1
    Using the srid (in this case, 26909) as in CreateSpatialReference_management(26909) worked for me. Thank you.
    – spindrift
    Nov 27 '14 at 22:01

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.