[GIS] Snapping point to point based on attribute

arcgis-desktopgeoprocessingsnapping

I'm using ArcMap.

I have two identical point feature classes, one snapped to a line and the other not. Each point represents a telecommunication pole and the line represents fiber optic cable. I sequence the poles to the fiber optic cable line using the 'Route Events GeoProcessing Wizard' which by design, snaps all points to the fiber cable. I then have to manually snap the points that don't belong on the fiber line manually, which is very time consuming. Is there a way to snap two identical point feature classes with unique ID's together, instead of snapping based off proximity?

Best Answer

You can move geometries using da.UpdateCursor:

pt_on_line = 'orginal_points'
pt_on_line_ID = 'FID' # common ID field
pt_off_line = 'points_to_move'
pt_off_line_ID = 'FID' # common ID field
pt_on_line_dict = {str(row[0]):row[1] for row in arcpy.da.SearchCursor(pt_on_line,[pt_on_line_ID,"SHAPE@"])} # make dictionary, like {ID:geometry}
with arcpy.da.UpdateCursor(pt_off_line,[pt_off_line_ID,"SHAPE@"]) as cursor:
    for row in cursor: # loop through points
        row[1] = pt_on_line_dict[str(row[0])] # move point geometry to match point geometry from dictionary
        cursor.updateRow(row) # update the geometry

Of course, Python is for consenting adults. This will move your data, so you may want to test on a backup.

Related Question