0

I need to delete some vertices from some polygon fc that are unnecessary for the geometry. I have a point shapefile that contains all unnecessary vertices as points - but how can I access the vertices and delete them with a python script or in model builder?

A similar problem has been described here:

Update geometry(polygon) of shapefile based on a point layer and here: https://community.esri.com/thread/95310 - but I can not install GeoWizard or use any other Software or FME solution because I am no administrator on my pc at work.

I need a python solution ArcGis 10.4.1, probably an UpdateCursor...

I can do this by selecting the single vertices and delete them, but I need an automated solution.

First Problem

I realized that my adjacent polygons share some vertices (in the second picture the one marked in red) - and my point shp does not give me any information which vertex should be deleted from which of the polygons. That is how some vertices are deleted and the geometry changes (third picture). Probably the red marked vertex should be deleted in the light brown polygon (and not from the one that is a bit darker).

But the script from BERA works perfectly for my initially described problem. I need to find a solution how to find the connection from the vertex to the polygon.

enter image description here

enter image description here

  • 1
    Are the Point and vertice at exactly the same coordinate? – BERA Jan 17 at 9:58
  • 1
    Comment to your last edit: Probably impossible if the Points does not have some attribute telling which polygon they belong to. – BERA Jan 22 at 12:46
  • 1
    I suggest you try other ways of deleting vertices. Like Integrate or Simplify Polygon – BERA Jan 22 at 12:57
  • 1
    Thank you - I tried 'Generalize' with 0 tolerance up to now... but it changed my geometries. Integrate or Simplify Polygon I will try now. – Frauke Jan 23 at 13:01
  • 1
    Integrate works very good for my purposes - thank you! – Frauke Jan 25 at 9:37
2

Code below will output a new feature class with the vertices intersecting the points removed.

import arcpy

precision = 1 #number of decimals to round coordinates when matching points to polygon vertices
point_fc = r'C:\Default.gdb\aPoint'
polygon_fc = r'C:\Default.gdb\aPoly'

polycopy = r'C:\Default.gdb\aPoly_copy'
arcpy.CopyFeatures_management(in_features=polygon_fc, out_feature_class=polycopy)

points = [(round(i[0][0],precision),round(i[0][1],precision)) for i in arcpy.da.SearchCursor(point_fc,'SHAPE@XY')]

#Recreate each polygon with all vertices but the ones matching the points
with arcpy.da.UpdateCursor(polycopy,'SHAPE@') as cursor:
    for row in cursor:
        polylist = []
        for part in row[0]:
            partlist = []
            for pnt in part:
                try:
                    if (round(pnt.X,precision), round(pnt.Y,precision)) not in points:
                        partlist.append(pnt)
                except AttributeError:
                    pass
            polylist.append(partlist)
        row[0] = arcpy.Polygon(arcpy.Array(polylist))
        cursor.updateRow(row)

enter image description here

  • The script does what it should - thanks a lot. Is there a possibility to still keep the Geometry? because I now realize that my point layer does not tell me in which of the adjacent Polygons the vertices are. So it kills some of the points that are important for the geometry and should only be eliminated for the adjacent polygon. I have to think about how to relate the points to the polygons. – Frauke Jan 18 at 12:03
  • @Frauke, I dont understand. Could you edit your question and add a screenshot? – BERA Jan 18 at 12:41
  • If the vertices of the adjacent polygons are not exactly at the same coordinates as the Points, increase precision to maybe 6, and it should work. – BERA Jan 18 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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