arcgis-desktop – Using Spatial References with ArcPy After *.prj Files No Longer Installed by ArcGIS 10.1

arcgis-10.1arcgis-desktoparcpycoordinate system

I'm writing a python script that uses the CreateFeatureclass_management tool, without a template. One of the required parameters is a spatial reference. I used to be able to point to the system *.prj file in 9.3, but that's no longer an option, and I don't want to point to an existing shapefile's *.prj because that will cause issues when I share the script.

Now that Esri doesn't install all the *.prj files with ArcGIS, how can I set the projection in a script without referencing an existing shapefile?

Best Answer

As stated in the help simply choose your spatial reference by name or factory code.

# Using spatial reference name
sr = arcpy.SpatialReference("Hawaii Albers Equal Area Conic")

# Using factory code
sr = arcpy.SpatialReference(32145)

You can find the list of spatial reference factory code here:

Related Question