longavailable / voronoi-diagram-for-polygons

A tool to create a Voronoi diagram for polygons
https://longlovemyu.com/voronoi-diagram-for-polygons/
MIT License
45 stars 10 forks source link

Generated voronoi regions interesect with geometries #4

Closed christianayala10 closed 1 year ago

christianayala10 commented 2 years ago

I have generated the voronoi regions (in red) for the geometries in blue. As it can be seen, the resulting voronoi regions interset with the original geometries. Any idea?

image

longavailable commented 1 year ago

Firstly, it is a very interesting feedback. Many thanks!

How did it happen?

Voronoi diagram for polygons is based on shapely.ops.voronoi_diagram.

As it mentioned in the mannual:

All vertices of the geometry will be used as the input points to the diagram.

Let us have a look on the geometries from your inputs.

Simple geometries with TOO less vertices!

Then it should be added more vertices along their edges.

I added a few to functions to reach it. See v0.1.3.

When you type:

vd = voronoiDiagram4plg(builtup, boundary)

It return the same output as you posted.

And when:

vd = voronoiDiagram4plg(input, boundary, densify=True)

It will proceed a automatical densifying preprocessing. And it will return the following.

image

It looks much better!

You can also assign an expected spacing to spacing parameter, for example:

vd = voronoiDiagram4plg(input, boundary, densify=True, spacing=5000)

At last, when you post a specific issue, it 's better to upload the related attachments. That will be time-saving for a reviewer.