Using Python to field calculate Lat/Long with decimal degrees rather than meters

المشرف العام

Administrator
طاقم الإدارة
The below is a snippet of a python script that I am writing that basically adds two fields - Latitude and Longitude, then calculates them. I could use the Add XY Tool which gets me to the same point. The way that I did it with the expression3 and expression4 variables should work but doesn't. The projection is WGS 84 the script works fully from start to finish. The columns are calculated in meters rather than decimal degrees which is what is needed for the project.

Any thoughts?

... ... ... ## Add Lat/Long Fields inFeature = "Point_Feature_Class" fieldName1 = "Latitude" fieldName2 = "Longitude" fieldType = "DOUBLE" arcpy.AddField_management(inFeature, fieldName1, fieldType) arcpy.AddField_management(inFeature, fieldName2, fieldType) ## Execute CalculateField of Lat/Long Fields expression1 = "{0}".format("!SHAPE.extent.XMax!") expression2 = "{0}".format("!SHAPE.extent.YMax!") #expression3 = "{0}".format("!SHAPE.extent@decimaldegrees!") #expression4 = "{0}".format("!SHAPE.extent@decimaldegrees!") arcpy.CalculateField_management(inFeature, fieldName1, expression1, "PYTHON_9.3") arcpy.CalculateField_management(inFeature, fieldName2, expression2, "PYTHON_9.3") #arcpy.CalculateField_management(inFeature, fieldName1, expression3, "PYTHON_9.3") #arcpy.CalculateField_management(inFeature, fieldName2, expression4, "PYTHON_9.3") ... ... ...

أكثر...
 
أعلى