Calculating the latitude and longitude of a point that is not in a geographic coordinate system was a tricky thing for me to figure out one day.
My data was not in the “World Projection” (as ArcMap calls it) so when I finally figured out how to access the x,y coordinates of the point, they were not in Lat/Long. So basically I reproject the file, extract the x,y coordinates, then reproject back to State Plane which is what I need. Not too elegant, but it gets the job done.
Here’s how I accomplished it:
import arcpy from arcpy import env myFC = "C:\\Temp\\temp.gdb\\mydata" myDataWGS= "c:\\temp\\temp.gdb\\myDataWGS" SR = 'c:\\temp\\decdeg.prj' #spatial reference set to geographic arcpy.env.outputCoordinateSystem = SR xExpression = 'float(!shape.firstpoint!.split() )' yExpression = 'float(!shape.firstpoint!.split() )' arcpy.MakeFeatureLayer_management(myFC, "myFC_lyr") #export and reproject at the same time, arcpy.AddField_management(myFC, "GIS_LAT", "FLOAT") arcpy.AddField_management(myFC, "GIS_LONG", "FLOAT") arcpy.CopyFeatures_management(myFC, myDataWGS) arcpy.MakeFeatureLayer_management(myDataWGS, "myDataWGS_lyr") #since the new FC has a geographic coordinate systems, the shape.firstpoint command will return a latitude and longitude try: arcpy.CalculateField_management("myDataWGS_lyr", "GIS_LONG", xExpression, "PYTHON") arcpy.CalculateField_management("myDataWGS_lyr", "GIS_LAT", yExpression, "PYTHON") except: print arcpy.GetMessages(2) sr = myFC #spatial reference set back to State Plane env.outputCoordinateSystem = sr arcpy.CopyFeatures_management("myDataWGS_lyr", "c:\\temp\\temp.gdb\\myData_final") # the final output carries the GIS_LAT and GIS_LONG fields along with it so they persist into the newly projected feature class print 'done'