New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Triangulation produces wrong results #764
Comments
@drnextgis And even if it would be a default behavior to return empty lists then it is definitely not consistent: from shapely.geometry import Polygon
from shapely.ops import triangulate
# this is broken:
p = Polygon([(0, 0), (1, 0), (-1, 0.05)])
triangulate(p)
# []
# but this works fine:
p = Polygon([(0, 0), (1, 0), (-1, 0.1)])
triangulate(p)[0].wkt
# 'POLYGON ((-1 0.1, 0 0, 1 0, -1 0.1))' Regarding the second and the third example. In your plot there is a missing line, hence missing triangle: Taking in mind the aforementioned property with the convex hull, we can also perform a simple check of resulting areas: # there is a bug here:
p = Polygon([(0, 0), (0, 486), (1, 486), (1, 22), (2, 22), (2, 0)])
p.convex_hull.area, sum(triangle.area for triangle in triangulate(p))
# (740.0, 497.0)
# this works fine though:
p = Polygon([(0, 0), (0, 200), (1, 200), (1, 22), (2, 22), (2, 0)])
p.convex_hull.area, sum(triangle.area for triangle in triangulate(p))
# (311.0, 311.0) |
Confirmed for both |
This appears to be fixed in latest GEOS (by libgeos/geos#728). Can Shapely confirm? |
Yes, I can confirm this is fixed with latest released GEOS and shapely. Thanks for the note! First example no longer gives an empty list:
And the second example also now gives all expected triangles:
and confirming the above result visually: |
Should be fixed by libgeos/geos#953 |
For some reason
shapely.ops.triangulate
doesn't like some geometries and loses their parts.Simple example:
And another one:
There is a missing triangle here.
But if I replace
486
by, for example,200
, then it will work fine:Shapely version: 1.6.4.post1, installed from conda.
The text was updated successfully, but these errors were encountered: