I always use arcpy.GetParameterAsText to get the spatial reference from the user. There should be a way to decide what is the spatial reference of a shapefile but I can't find it. Something like Describe....
SR = arcpy.Describe(inFC).spatialReference
where inFC is an input shapefile or feature class. It returns a SpatialReference object.
if you want to spell out the name of the Spatial reference for feature class
# Get spatial reference of the feature class spatialRef = arcpy.Describe(fc).SpatialReference # print the spatial reference print spatialRef.Name
Printing only the
.Name at the end) prints only
print spatialRef <geoprocessing spatial reference object object at 0x06623080>
returns the name of CS:
(based on GIS Programming and Automation class: https://www.e-education.psu.edu/geog485/node/115 )