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?

closed as off-topic by Kadir Şahbaz, Vince, whyzar, BERA, ThingumaBob Oct 12 '18 at 11:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – Kadir Şahbaz, Vince, whyzar, BERA, ThingumaBob
If this question can be reworded to fit the rules in the help center, please edit the question.

  • might be helpful, gis.stackexchange.com/questions/78541/… – klewis Oct 11 '18 at 17:27
  • Add geometry attributes to footprints. Join to first one and apply arcpy.Point (point,pointy) on shape field. – FelixIP Oct 11 '18 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 '18 at 20:20
  • I understood what you were saying, you didn't understand what I suggested. – FelixIP Oct 11 '18 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 '18 at 14:12

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.



arcpy.AddGeometryAttributes_management("POLYGONS", "CENTROID")
arcpy.AddGeometryAttributes_management("POINTS", "POINT_X_Y_Z_M")
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")
arcpy.CalculateField_management("POINTS", "Shape",
                                "arcpy.Point( !POINT_X!, !POINT_Y!)")


enter image description here


enter image description here


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

  • 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 '18 at 19:04

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