-1

I am trying to shift a large number of point features (layer name Building_Point_NeedToSnap) to a newly created second set of point features (layer name BuildingFootprint_XYTablePoint) which is based on a polygon feature centroid. Both features share identical attribution in a field named PARCEL.

Is there a way to snap two similar point feature classes with correlating fields together as opposed to proximity based snapping?

5
  • might be helpful, gis.stackexchange.com/questions/78541/…
    – klewis
    Oct 11, 2018 at 17:27
  • Add geometry attributes to footprints. Join to first one and apply arcpy.Point (point,pointy) on shape field.
    – FelixIP
    Oct 11, 2018 at 19:58
  • To clarify in this instance I am specifically trying to attach point feature to point feature. I already used Add Geometry to Attribute to to add XY values to my polygons, then used XY Table to Point to create the centroid point features I would be snapping to
    – SalasJ
    Oct 11, 2018 at 20:20
  • I understood what you were saying, you didn't understand what I suggested.
    – FelixIP
    Oct 11, 2018 at 22:47
  • The mods here get super pissed if you haven't got your code done by the time you get here. It's really unfortunate, but you'll need to jot down some of the code you used in order to open your question up so the mods feel like they aren't writing your code for you for free.
    – user125266
    Oct 12, 2018 at 14:12

3 Answers 3

4

Just change the points xy to that of the parcel's centroid. You can get centroid coordinates from parcels by adding 'SHAPE@XY' to the fields list in your cursor. That should also work for getting your point coordinates. You should use a search cursor to build a dictionary with the centroid coordinates using parcels they points are on as keys.

Then you can lookup your values later when you loop through your update cursor. Your update cursor should be running on the features you want to add your points to.

Really, if you're using cursors to work, the best you can do here is to simulate a join using a dictionary. This method is well documented in many other places, and in general it performs much faster than arcpy's join functions do. This technique won't create any weird side effects in your maps either; no problematic shape file. It's also worth noting that if you're moving a lot of data you can run out of memory with arcpy's join functions so this dictionary powered "look up" based approach is necessary, the only way with python, in some situations.

1

Workflow:

arcpy.AddGeometryAttributes_management("POLYGONS", "CENTROID")
arcpy.AddGeometryAttributes_management("POINTS", "POINT_X_Y_Z_M")
# TRANSFER CENTROID XY TO POINTS TABLE
arcpy.AddJoin_management("POINTS", "POINT_ID", "POLYGONS", "PGON_ID")
arcpy.CalculateField_management("POINTS", "centres.POINT_X", "[POLYGONS.CENTROID_X]")
arcpy.CalculateField_management("POINTS", "centres.POINT_Y", "[POLYGONS.CENTROID_Y]")
arcpy.RemoveJoin_management("POINTS", "POLYGONS")
# AND MOVE POINTS
arcpy.CalculateField_management("POINTS", "Shape",
                                "arcpy.Point( !POINT_X!, !POINT_Y!)")

BEFORE:

enter image description here

AFTER:

enter image description here

0

I had a similar problem that I was able to get help with here. I didn't use snap though and instead joined the my addresses points to the building centroids.

Moving points to the largest polygon within another polygon

1
  • Tom thanks for the advice, but I'm afraid a spatial join won't do the trick in this instance. Unfortunately the additional shape file created by the join is problematic for my current project. The specific intent is to update the Building_Point_NeedToSnap point locations in the existing shapefile.
    – SalasJ
    Oct 11, 2018 at 19:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.