Skip to content
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

Voronoi diagram contains collection with a LineString #1062

Open
martinfleis opened this issue Mar 25, 2024 · 0 comments
Open

Voronoi diagram contains collection with a LineString #1062

martinfleis opened this issue Mar 25, 2024 · 0 comments

Comments

@martinfleis
Copy link

martinfleis commented Mar 25, 2024

I've found a pathological case where the result of voronoi polygons contains LineStrings. See the example below, using shapely built against GEOS 3.12.1.

import shapely

points_input = shapely.MultiPoint(
    (
        (-819831.1, -1007946.473), 
        (-819831.1, -1007945.994),
        (-819829.184, -1007947.9099999999),
        (-819829.663, -1007947.9099999999),
    )
)
voronoi = shapely.voronoi_polygons(
    points_input
)
shapely.get_parts(voronoi)

array([<POLYGON ((-819827.268 -1007944.078, -819827.268 -1007949.826, -819829.424 -...>,
       <POLYGON ((-819833.016 -1007944.078, -819827.268 -1007944.078, -819829.424 -...>,
       <POLYGON ((-819833.016 -1007949.826, -819833.016 -1007946.234, -819829.424 -...>,
       <GEOMETRYCOLLECTION (POLYGON ((-819833.016 -1007949.826, -819829.424 -100794...>],
      dtype=object)

The last collection contains a Polygon and a tiny LineString, but the presence of the LineString causes failure when using coverage union later.

The issue is most likely caused by the floating point in those y coords and setting the precision grid resolves it (edit: it does in this case but not in others I've found). But I don't think that the algorithm should result in a LineString in any situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant