I'm trying to use ArcGIS Pro to calculate the lat/long of a point in decimal degrees. I must not be understanding the help section below. In the calculate field I enter !SHAPE.FirstPoint.X@decimaldegrees! but it fails because decimaldegrees is not defined...
Python expressions can be created using properties from the Geometry object including type, extent, centroid, firstPoint, lastPoint, area, length, isMultipart, and partCount (for example, !shape.area!).
Python expressions can use the geometry area and length properties with an areal or linear unit to convert the value to a different unit of measure (for example, !shape.length@kilometers!).
Since you are working in an Enterprise Geodatabase Environment it is hard to tell why this is locked. It lockes when trying to create the fields - even if this is a process that accepts existing fields. I can make another modification - and remove the ATTEMPT to create the fields as they are never actually need to be added - I've updated the attachement above. I left the warning for existing fields in there but added a counter-message that tells you how many records are updated. Keep in mind: I only check for the LAT field being NULL ... if so - record is updated .... I renamed the UI-selection to be POINT_LAT_LONG only to reflect more what you do ... hope it works for you - then you owe me a beer 🙂 and some points here 🙂
That is some impressive script wizardry! It worked and did what I needed. Thank you so much! I appreciate you taking the time to help me out.
I really appreciate your help. I tried your tool but it failed and this is what I got:
Start Time: Thursday, July 20, 2017 8:56:42 AMRunning script UpdateLATLONG... WARNING 001097: LAT already exists -- overwriting.Failed script UpdateLATLONG...Traceback (most recent call last): File "C:\Users\spsummers\Downloads\CalcGeometryModified\CalcGeometryModified.tbx#UpdateLATLONG_CalcGeometryModified.py", line 387, in <module> File "C:\Users\spsummers\Downloads\CalcGeometryModified\CalcGeometryModified.tbx#UpdateLATLONG_CalcGeometryModified.py", line 61, in execute File "C:\Users\spsummers\Downloads\CalcGeometryModified\CalcGeometryModified.tbx#UpdateLATLONG_CalcGeometryModified.py", line 313, in CreateOutputFieldsRuntimeError: Table is already locked [Table is already locked[gis.GISDB.AddressPoints.LONG]]Failed to execute (UpdateLATLONG).Failed at Thursday, July 20, 2017 8:58:06 AM (Elapsed Time: 1 minutes 24 seconds)
I know some very basic python but this is a little over my head.
Hi all,
In Pro as in Map there is a script based tool called "Add Geometry ...". The script is pretty elaborate but with a few minor changes and "reductions" it should do what you want. Find attached a toolbox with a modified sript ingested in it that (from analyzing the text above) does pretty much what you want:
What I didnt do:
Give it a try or export the script from the toolbox and modify. All modifications to the original esri version I made can be found in the python code by searching for comments starting with #GD:
RegardsGuenter
You are correct that I can run the tool on a selected point and get the coordinates I want. The problem I am having is that this tool creates its own fields to store the coordinates. I can not add fields to my point feature class. It is in an SDE environment and my organization has all of the fields already set up and I do not have permissions to add further fields. As I stated above, I know that I could create my own temporary point fc just to calculate these coordinates and then copy and paste them in, but I was hoping for a simpler solution like the old "Calculate Geometry". I added my question to this string because I too was trying to use the !SHAPE.centroid.X@decimaldegrees! with the Field Calculator thinking I had found a work around. I appreciate any ideas and thank you for your time.
Sean - you could use the Add Geometry Attributes GP tool on the selected records and obtain the Point x, y, z and m coordinates. In the GP parameters, set the Coordinate System to WGS1984 to obtain the lat/long fields. Hope this helps!
I'm not sure how this would work for me. Perhaps you might have a better idea? I have an existing building points feature class (it's in State Plane feet) and it already has an existing LAT and LONG field. If a new building is constructed I add a new point and I need to calculate the LAT and LONG. In desktop I would just open the attribute table and "Calculate Geometry" and choose Decimal Degrees. Is there no way to do something similar in PRO? It appears the "Add XY Coordinates" tool would calculate the fields for the entire feature class? Am I missing something simple and stupid or do I really have to go through a long convoluted process to do this? Any suggestions would be greatly appreciated.
In ArcGIS Pro, you could use the Add XY Coordinates GP tool to create 2 new attribute fields. If your data is in another coordinate system, go the Environment Settings of the GP tool and set the Coordinate System to be WGS 1984. By doing this, the PointX and PointY attribute fields will calculate Decimal-Degrees.
apparently that isn't used for getting the coordinates of points in a GSC according to other reports... for example...
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.