As part of a longer script I'm writing, I need to add fields to my points layer and put the lat/long coordinates in those fields. This is so EASY to do manually by opening the attributes table, adding the fields, and doing a "Calculate geometry." There's an option to tell it what units you want.
I keep trying to find a way to do this with python geoprocessing, and I can't figure it out.
I was using AddXY_Management, but this only yields the X and Y coordinates in whatever projection my points layer happens to be in. CalculateField_Management won't let me specify the units for a points layer (or if it does, I can't figure out how).
Anyone know how to do this? I feel like it should be easy and I'm just missing the magic python command.
That is super annoying. That's what I was trying to avoid. A points layer in a projected coordinate system has a geographic coordinate system with lat/long underneath, right? For that reason, I don't see why there isn't a way to get lat/long even if the data is projected.
I agree, but there is only one coordinate system for the coordinates, long/lat and projected coordinates aren't stored in the same file. It should operate as the calculate geometry done via the interface. If you are interested post on the ArcGIS Ideas site http://ideas.arcgis.com/