-
Notifications
You must be signed in to change notification settings - Fork 24
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
Bounding box support for geoVoronoi #46
Comments
Good question! It makes sense to clip spherical coordinates to a rectangular bounding-box is when the projection is cylindrical (Mercator or equirectangular, for example). Otherwise the clipped area can be unexpected: Of course, if the region you're working on is very small, it's a good idea to project first with a locally conformal projection, then compute the voronoi tessellation (with clipping) on the resulting pixel coordinates. turf.voronoi doesn't do this, and as a consequence is not accurate outside of the equatorial region if you feed it spherical coordinates. When you need a large region of the globe and want a correct spherical voronoi, you can use d3-geo-voronoi, and then clip its polygons to a rectangle. It can be done with the clipExtent option of d3-geo's projections: d3.geoMercator()
.fitExtent([[10, 10],[630, 490]], points)
.clipExtent([[1, 1], [639, 499]]) |
One last question. Since my main goal is to produce a GeoJSON output from a BBox bounded Voronoi diagram (for further processing) and not to produce a d3 rendering, is there an easy approach to achieve? I mean the mentioned clipping based on a d3 projection only works for a d3 rendering context, right? |
I knew you'd want that :) |
@Fil Thank you so much! You made my day! The world needs more developers like you! |
Currently one is able to generate Voronoi polygons by passing a set of points. Unfortunately there is no support for bounding box clipping like the
Delaunay.vornoi(bbox)
or theturf.voronoi(points, { bbox })
function. Is it possible that this functionality can be added or is there another way to achieve this?The text was updated successfully, but these errors were encountered: