Solved! Go to Solution.
NOTE: as of Version 10.3, the SpatialReference object contains the "latitudeOfOrigin" property, and the trick below is unncessary.
Hi Tim,
It looks like a property which should be included in the SpatialReference object, but I don't see it either. For a quick and dirty hack, you can pull the relevant string out of the exportToString() results:
import arcpy import re # a projection with a latitude of origin property proj = 'NAD 1983 Contiguous USA Albers' sr = arcpy.SpatialReference(proj) lat_of_origin_regex = "Latitude_Of_Origin',(\d+\.?\d*)]" match = re.search(lat_of_origin_regex, sr.exportToString()) if match: lat_of_origin = float(match.groups()[0]) print "{0} has latitude of origin {1}".format(proj, lat_of_origin) else: print "no latitude of origin detected."
Set up your own spatial reference object in the code above, and you should be able to use the lat_of_origin variable to get what you need.
cheers, Shaun
NOTE: as of Version 10.3, the SpatialReference object contains the "latitudeOfOrigin" property, and the trick below is unncessary.
Hi Tim,
It looks like a property which should be included in the SpatialReference object, but I don't see it either. For a quick and dirty hack, you can pull the relevant string out of the exportToString() results:
import arcpy import re # a projection with a latitude of origin property proj = 'NAD 1983 Contiguous USA Albers' sr = arcpy.SpatialReference(proj) lat_of_origin_regex = "Latitude_Of_Origin',(\d+\.?\d*)]" match = re.search(lat_of_origin_regex, sr.exportToString()) if match: lat_of_origin = float(match.groups()[0]) print "{0} has latitude of origin {1}".format(proj, lat_of_origin) else: print "no latitude of origin detected."
Set up your own spatial reference object in the code above, and you should be able to use the lat_of_origin variable to get what you need.
cheers, Shaun
Note there are no more system-based .prj file in v10.1 anymore (!!!!) But you can manufacture one via the SR's exportToString() method and then write it to a file.
Seems like a bug to not have that property available...
Note there are no more system-based .prj file in v10.1 anymore (!!!!) But you can manufacture one via the SR's exportToString() method and then write it to a file.
thanks for this answer!
Note: with 10.3 you'll need to use lat_of_origin_regex = "latitude_of_origin',(\d+\.?\d*)" with lowercases
also, you can also use the factoryCode in the arcpy.SpatialReference()