-
Notifications
You must be signed in to change notification settings - Fork 560
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
Polylabel bug #817
Comments
Could you please verify that the coordinate that https://github.com/mapbox/polylabel itself suggests is different? |
Original algorithm in TypeScript: import polylabel from "polylabel";
let exterior = [[0,0],[10,0],[10,10],[0,10],[0,0]];
let hole = [[2,2],[6,2],[6,6],[2,6],[2,2]];
let polygon = [exterior, hole]
console.log(polylabel(polygon, 0.01));
Shapely:
|
You are correct @benediktbrandt. The Shapely implementation doesn't handle the holes correctly, as it only considers the distance to the exterior of the polygon. I think this is a bug this should be fixed to match the behaviour of the original algorithm. The conversion of the polygon exterior to a linestring is a little inefficient here too as it will be done for every cell created. |
Expected behavior and actual behavior.
Holes are not correctly accounted for in shapely's implementation of the polylabel algorithm.
Steps to reproduce the problem.
The output of this script is:
But the correct position is something close to 7.65625, 7.65625. This can be verified by looking at a plot of this polygon
Maybe I am doing something wrong in the definition of the polygon but I have tried many different ways of instantiating this polygon and I always get the same result.
Operating system
Linux
Shapely version and provenance
Tested with shapely version 1.6 and 1.7a3
The text was updated successfully, but these errors were encountered: