Select to view content in your preferred language

Correcting Drift

384
2
03-15-2023 02:18 AM
Maps-Berlin
New Contributor III

Hey everyone,

I am working with shapefiles which in part contain the same points but I assume due to reprojections in the past or possibly recalculations of geometries with different accuracies, those points drifted apart and i am now left with files that plot like this:

MapsBerlin_0-1678871437310.png

Is there any tools availible to identify and correct this drift so I can properly identify the matching points? Sadly the drift is not completely uniform across all points so simply moving all points by x/y is not an option. 

Any ideas appreciated. Thanks a lot.

 

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

If you have a unique id field with the same values in the wrong and correct layers, you can use a little Python script:

# parameters
wrong_geometries_fc = "TestPoints"  # layer name or path to the shapefile
wrong_geometries_id_field = "IntegerField2"  # name of the id field
correct_geometries_fc = "TestPointsAGOL"
correct_geometries_id_field = "IntegerField2"

# read the correct geometries
correct_geometries = {i: shp for i, shp in arcpy.da.SearchCursor(correct_geometries_fc, [correct_geometries_id_field, "SHAPE@"])}

# iterate over the wrong geometries
with arcpy.da.UpdateCursor(wrong_geometries_fc, [wrong_geometries_id_field, "SHAPE@"]) as cursor:
    for i, shp in cursor:
        # find the correct geometry and update
        try:
            correct_geometry = correct_geometries[i]
            cursor.updateRow([i, correct_geometry])
        except KeyError:
            print(f"No correct geometry found for {wrong_geometries_id_field} = {i}")

Have a great day!
Johannes
0 Kudos
Maps-Berlin
New Contributor III

Hey Johannes, 

thank you for your reply. Sadly I have nothing in the Attributes to reference those two files with one another. Plus (I am guessing) this would only correct the matching points and leave all non matching points as is, the drift is affecting all points though and I was hoping to find a tool which identifies the drift based on the matching points and then applies a correction to all points. Now that I write that out I realize that I should maybe look into machine learning. 

0 Kudos