1

I would like to triangulate the following polygon:

enter image description here

The wkt for the geometry is given as follows:

POLYGON ((3 0, 2 0, 2 0.75, 2.5 0.75, 2.5 0.6, 2.25 0.6, 2.25 0.2, 3 0.2, 3 0))

I ran this code to generate the triangles

triangles = shapely.ops.triangulate(res_intersection.geometry.values[0])
triangles_gdf = geopandas.GeoDataFrame()
triangles_gdf.geometry = triangles

When I take a look at the resulting polygon this is what I get:

enter image description here

However this is not what I want. The algorithm seems to generate some extra triangles which Are not contained in the original geometry. Why does this occur? Is there a workaround for this? Ultimately I would like to triangulate a large irregular polygon with holes.

1

It is not producing an 'erratic' result. it takes the vertices as inputs as stated in the manual:

https://shapely.readthedocs.io/en/stable/manual.html#shapely.ops.triangulate

Nothing stops you from clipping the result with the original shape, if that is what you want.

  • you can, but that comes with the additional overhead associated with geopandas.overlay – user32882 Mar 26 at 11:52

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.