Skip to main content
Should use del and not pop()
Source Link
ianbroad
  • 9.1k
  • 4
  • 43
  • 88

As mentioned above, you can use:

arcpy.SimplifyPolygon_cartography("polygon", "output", "POINT_REMOVE", 1)

You might have to tweak the tolerance- I'm not real familiar with how it works.

You could also do this using geometry, but there are a lot of factors that go along with it. It's hard to tell by your question if this is for many features, or just one feature. If it is more than one feature, is the scenario the same for each one?

If it is always the first/last point you want removed, then this should work:

search = arcpy.da.SearchCursor("existing polygon", "SHAPE@")
insert = arcpy.da.InsertCursor("new polygon", "SHAPE@")

for row in search:
    points = [arcpy.Point(point.X, point.Y) for shape in row[0] for point in shape]

    points.pop(0)del points[0]
    points.pop(del points[-1)1]
    points.append(points[0])
        
    array = arcpy.Array(points)
    polygon = arcpy.Polygon(array)
        
    insert.insertRow([polygon])

As mentioned above, you can use:

arcpy.SimplifyPolygon_cartography("polygon", "output", "POINT_REMOVE", 1)

You might have to tweak the tolerance- I'm not real familiar with how it works.

You could also do this using geometry, but there are a lot of factors that go along with it. It's hard to tell by your question if this is for many features, or just one feature. If it is more than one feature, is the scenario the same for each one?

If it is always the first/last point you want removed, then this should work:

search = arcpy.da.SearchCursor("existing polygon", "SHAPE@")
insert = arcpy.da.InsertCursor("new polygon", "SHAPE@")

for row in search:
    points = [arcpy.Point(point.X, point.Y) for shape in row[0] for point in shape]

    points.pop(0)
    points.pop(-1)
    points.append(points[0])
        
    array = arcpy.Array(points)
    polygon = arcpy.Polygon(array)
        
    insert.insertRow([polygon])

As mentioned above, you can use:

arcpy.SimplifyPolygon_cartography("polygon", "output", "POINT_REMOVE", 1)

You might have to tweak the tolerance- I'm not real familiar with how it works.

You could also do this using geometry, but there are a lot of factors that go along with it. It's hard to tell by your question if this is for many features, or just one feature. If it is more than one feature, is the scenario the same for each one?

If it is always the first/last point you want removed, then this should work:

search = arcpy.da.SearchCursor("existing polygon", "SHAPE@")
insert = arcpy.da.InsertCursor("new polygon", "SHAPE@")

for row in search:
    points = [arcpy.Point(point.X, point.Y) for shape in row[0] for point in shape]

    del points[0]
    del points[-1]
    points.append(points[0])
        
    array = arcpy.Array(points)
    polygon = arcpy.Polygon(array)
        
    insert.insertRow([polygon])
Source Link
ianbroad
  • 9.1k
  • 4
  • 43
  • 88

As mentioned above, you can use:

arcpy.SimplifyPolygon_cartography("polygon", "output", "POINT_REMOVE", 1)

You might have to tweak the tolerance- I'm not real familiar with how it works.

You could also do this using geometry, but there are a lot of factors that go along with it. It's hard to tell by your question if this is for many features, or just one feature. If it is more than one feature, is the scenario the same for each one?

If it is always the first/last point you want removed, then this should work:

search = arcpy.da.SearchCursor("existing polygon", "SHAPE@")
insert = arcpy.da.InsertCursor("new polygon", "SHAPE@")

for row in search:
    points = [arcpy.Point(point.X, point.Y) for shape in row[0] for point in shape]

    points.pop(0)
    points.pop(-1)
    points.append(points[0])
        
    array = arcpy.Array(points)
    polygon = arcpy.Polygon(array)
        
    insert.insertRow([polygon])