Select to view content in your preferred language

I need to bulk update the location of points

745
2
11-04-2022 06:48 AM
LLCCG
by
New Contributor III

I have a feature class that has several million address points. A small percentage of them are not terribly accurate, but a small percentage of several million is still too many to update one at a time. We have some code that interpolates a more accurate X,Y location based on nearby addresses that are accurately placed. 

So now I have a table of new X,Y coordinates and I need to move the existing points to those coordinates. I can't, unfortunately, just use Display XY, append the new feature class to the original, and replace the old entries. The GlobalID for the original feature has to stay the same. 

I can use the Move To tool to update one at a time, but that would be really unpleasant. 

Is there a tool I can use to do them all at once?

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

There is a GIS Stack Exchange question that seems pretty similar to this. It looks pretty straightforward, but the new coordinates need to be fields in your table. Maybe you can do an attribute-based join of the new table and the points layer, then attempt the solution?

https://gis.stackexchange.com/a/252369

If you're working through AGOL / Portal, the ArcGIS Python API also has some capability to do this, but the linked answer above seems simpler.

- Josh Carlson
Kendall County GIS
0 Kudos
LLCCG
by
New Contributor III

This works when I use it against a shapefile. But I need to run it on a versioned enterprise geodatabase. When I run the script, it give me an error saying that it has to be done in an edit session. There's a post on stackexchange that says to use Arcpy.da.Editor. 

The Editor documentation  looks like that tool does exactly what I need. 

Should my code just be something like this then?

import arcpy
import os

feature_class=r'<Path>\DB.sde\DB.DBO.Addresses'
fields=['Longitude','Latitude']

with arcpy.da.Editor(os.path.dirname(feature_class), multiuser_mode=True):

with arcpy.da.UpdateCursor(feature_class,['SHAPE@X','SHAPE@Y']+fields) as cursor:
for row in cursor:
row[0]=float(row[2])
row[1]=float(row[3])
cursor.updateRow(row)

0 Kudos