<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Upate Geometry fields in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162752#M64314</link>
    <description>&lt;P&gt;I did catch that after I posted my question. After doing some more digging/searching I did notice that if I had the attribute table open in Pro the X &amp;amp; Y fields didn't update. I closed the attribute table and re-opened it and the fields were updated with arcpy.AddGeometryAttributes_management, but I am still getting the error even after the fields update. The layer is check on the Contents List by editing and I have also unchecked it.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Apr 2022 21:36:33 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2022-04-08T21:36:33Z</dc:date>
    <item>
      <title>Upate Geometry fields</title>
      <link>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162662#M64310</link>
      <description>&lt;P&gt;Trying to convert some of my ArcMap Scripts to Pro,&amp;nbsp; I am having a hard time with the arcpy.AddGeometryAttributes_management. but I keep getting the error and currently Running this in python window in Pro to test before I put it in a Pro toolbox script. I need some help please.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
File "&amp;lt;string&amp;gt;", line 23, in &amp;lt;module&amp;gt;
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 3724, in AddGeometryAttributes
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 3721, in AddGeometryAttributes
retval = convertArcObjectToPythonObject(gp.AddGeometryAttributes_management(*gp_fixargs((Input_Features, Geometry_Properties, Length_Unit, Area_Unit, Coordinate_System), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in &amp;lt;lambda&amp;gt;
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Traceback (most recent call last):
File "c:\program files\arcgis\pro\Resources\ArcToolbox\scripts\AddGeometryAttributes.py", line 397, in &amp;lt;module&amp;gt;
addGeomAtts.execute()
File "c:\program files\arcgis\pro\Resources\ArcToolbox\scripts\AddGeometryAttributes.py", line 98, in execute
edit.stopEditing(True)
RuntimeError: start edit session&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, string, os

workspace = r"C:\Users\***\AppData\Roaming\Esri\ArcGISPro\Favorites\Server.sde"

aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
lyr = m.listLayers("FC_layer")[0]

workspace = os.path.dirname(aprx.filePath)
wp = os.path.dirname(aprx.filePath)


##
if int(arcpy.GetCount_management(lyr).getOutput(0)) &amp;gt; 0:
    arcpy.AddGeometryAttributes_management(lyr,"POINT_X_Y_Z_M","", "", arcpy.SpatialReference("WGS 1984"))


##fields=['POINT_X','POINT_Y'] #Change to match your column names containing x and y coordinates
##
##with arcpy.da.UpdateCursor(lyr,['SHAPE@X','SHAPE@Y']+fields) as cursor:
##    for row in cursor:
##        if None in row:
##            row[0] = float(row[2])
##            row[1] = float(row[3])
##            cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried an updatecursor but get the following error.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;row[0]=float(row[2])
TypeError: float() argument must be a string or a number, not 'NoneType'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 21:50:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162662#M64310</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2022-04-08T21:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Upate Geometry fields</title>
      <link>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162717#M64311</link>
      <description>&lt;P&gt;arcpy.AddGeometryAttributes_management(&lt;STRONG&gt;""FC_layer""&lt;/STRONG&gt;,"POINT&lt;/P&gt;&lt;P&gt;this isn't going to work either it needs to be a variable not a string&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/add-geometry-attributes.htm" target="_blank"&gt;Add Geometry Attributes (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 20:08:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162717#M64311</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-04-08T20:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: Upate Geometry fields</title>
      <link>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162744#M64313</link>
      <description>&lt;P&gt;You already defined the layer you want as variable lyr.&lt;/P&gt;&lt;P&gt;You need to replace "FC_Layer" in the GetCount, AddGeometry and the cursor to lyr.&lt;/P&gt;&lt;P&gt;Also, on the cursor (if you use that):&lt;/P&gt;&lt;P&gt;if None in row:&lt;/P&gt;&lt;P&gt;&amp;nbsp;is telling it to only process on None (null/empty) data, so will throw the 'NoneType' error.&lt;/P&gt;&lt;P&gt;Did not test that, but replacing the text "FC_layer" with the variable lyr worked in my testing on the AddGeometry part.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 21:21:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162744#M64313</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-04-08T21:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Upate Geometry fields</title>
      <link>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162752#M64314</link>
      <description>&lt;P&gt;I did catch that after I posted my question. After doing some more digging/searching I did notice that if I had the attribute table open in Pro the X &amp;amp; Y fields didn't update. I closed the attribute table and re-opened it and the fields were updated with arcpy.AddGeometryAttributes_management, but I am still getting the error even after the fields update. The layer is check on the Contents List by editing and I have also unchecked it.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 21:36:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162752#M64314</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2022-04-08T21:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Upate Geometry fields</title>
      <link>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162753#M64315</link>
      <description>&lt;P&gt;Well, you got better response that I did.&amp;nbsp; I had to completely close Pro and open it again before I could see the new fields.&amp;nbsp; Maybe because I tested in a Notebook.&lt;/P&gt;&lt;P&gt;I didn't test with versioned data, if that is the case, might explain the error.&lt;/P&gt;&lt;P&gt;Did you try encompassing the code in an &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/editor.htm" target="_self"&gt;editor session&lt;/A&gt;?&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 21:43:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162753#M64315</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-04-08T21:43:18Z</dc:date>
    </item>
    <item>
      <title>Re: Upate Geometry fields</title>
      <link>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162754#M64316</link>
      <description>&lt;P&gt;I have fixed line 14 to lyr, I was doing some testing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, string, os

workspace = r"C:\Users\***\AppData\Roaming\Esri\ArcGISPro\Favorites\Server.sde"

aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
lyr = m.listLayers("FC_layer")[0]

workspace = os.path.dirname(aprx.filePath)
wp = os.path.dirname(aprx.filePath)


##
if int(arcpy.GetCount_management(lyr).getOutput(0)) &amp;gt; 0:
    arcpy.AddGeometryAttributes_management(lyr,"POINT_X_Y_Z_M","", "", arcpy.SpatialReference("WGS 1984"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I first create the points they are all &amp;lt;Null&amp;gt; which is why I used None in row:&lt;/P&gt;&lt;P&gt;But even without "None in row:"&amp;nbsp; I get the same error.&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;float() argument must be a string or a number, not 'NoneType'&lt;/SPAN&gt;"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, string, os

workspace = r"C:\Users\***\AppData\Roaming\Esri\ArcGISPro\Favorites\Server.sde"

aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
lyr = m.listLayers("FC_layer")[0]

workspace = os.path.dirname(aprx.filePath)
wp = os.path.dirname(aprx.filePath)

fields=['POINT_X','POINT_Y'] #Change to match your column names containing x and y coordinates

with arcpy.da.UpdateCursor(lyr,['SHAPE@X','SHAPE@Y']+fields) as cursor:
    for row in cursor:
        if None in row:
            row[0] = float(row[2])
            row[1] = float(row[3])
            cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 21:53:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162754#M64316</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2022-04-08T21:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Upate Geometry fields</title>
      <link>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162756#M64317</link>
      <description>&lt;P&gt;I did, I get the same thing. It works but I still get that error message in the python window.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have a lot of "Add-in" from ArcMap that I need to convert. The more I use Pro the less I am liking it.&lt;/P&gt;&lt;P&gt;I do appreciate the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, string, os

workspace = r"C:\Users\***\AppData\Roaming\Esri\ArcGISPro\Favorites\Server.sde"

aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps()[0]
lyr = m.listLayers("FC_layer")[0]

workspace = os.path.dirname(aprx.filePath)
wp = os.path.dirname(aprx.filePath)

### Start an edit session. Must provide the workspace.
edit = arcpy.da.Editor(workspace)
##
### Edit session is started without an undo/redo stack for versioned data
###  (for second argument, use False for unversioned data)
edit.startEditing(True)
##
### Start an edit operation
edit.startOperation()

##
if int(arcpy.GetCount_management(lyr).getOutput(0)) &amp;gt; 0:
    arcpy.AddGeometryAttributes_management(lyr,"POINT_X_Y_Z_M","", "", arcpy.SpatialReference("WGS 1984"))


##fields=['POINT_X','POINT_Y'] #Change to match your column names containing x and y coordinates
##
##with arcpy.da.UpdateCursor(lyr,['SHAPE@X','SHAPE@Y']+fields) as cursor:
##    for row in cursor:
##        if None in row:
##            row[0] = float(row[2])
##            row[1] = float(row[3])
##            cursor.updateRow(row)

### Stop the edit operation.
edit.stopOperation()
##
### Stop the edit session and save the changes
edit.stopEditing(True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 22:00:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162756#M64317</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2022-04-08T22:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Upate Geometry fields</title>
      <link>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162759#M64318</link>
      <description>&lt;P&gt;You are trying to set your &lt;A href="mailto:SHAPE@X" target="_blank" rel="noopener"&gt;SHAPE@X&lt;/A&gt;&amp;nbsp;field equal to the value in the POINT_X field float() doesn't work on a geometry object.&amp;nbsp; Same with the Y.&lt;/P&gt;&lt;P&gt;You&amp;nbsp; want the exact opposite.&amp;nbsp; set the value of the POINT_X field to the X value of the geometry object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor(lyr,['SHAPE@X','SHAPE@Y'] + fields) as cursor:
    for row in cursor:
        if row:
            row[2] = float(row[0])
            row[3] = float(row[2])
            cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will take the x and y values of the geometry and populate the new x and y fields.&lt;/P&gt;&lt;P&gt;also, I changed it to if row:&lt;/P&gt;&lt;P&gt;that way, if the row is empty, it won't try to do anything with it.&amp;nbsp; Shouldn't really need since you are iterating through all the features in the FC.&amp;nbsp; However, might save an error if there are some empty geometries in the FC.&lt;/P&gt;&lt;P&gt;Of course, the cursor isn't needed since the AddGeometry... not only adds the fields, but populates them.&lt;/P&gt;&lt;P&gt;Cursor would be good to update that info if you move the point.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 22:18:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162759#M64318</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-04-08T22:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Upate Geometry fields</title>
      <link>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162764#M64319</link>
      <description>&lt;P&gt;Good catch, I was looking at this for a few hours LOL.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 22:24:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/upate-geometry-fields/m-p/1162764#M64319</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2022-04-08T22:24:55Z</dc:date>
    </item>
  </channel>
</rss>

