[postgis-users] voronoi fails on regular grid
J.J. Green
j.j.green at gmx.co.uk
Sun Feb 25 08:03:56 PST 2018
Hi Darafei,
Many thanks for your reply
> Please post your points to https://trac.osgeo.org/geos/ as a bug report.
I'll do that
> In my experience two things help with Voronoi issues:
> - ST_SnapToGrid;
> - falling back to non-geos voronoi implementation,
In fact the first of those works beautifully -- I tried several
values and found that dyadic fractions (as in 1/2^n) work best,
this kind-of makes sense since it "zeros-out" the bottom-end of
the floats, and then calculations with them should be exact
(provided the input numbers are of the same order, and they are).
For the sake of others happening across this issue, my
working Voronoi call is now
CREATE TEMPORARY TABLE cell_poly_tmp ON COMMIT DROP AS
SELECT
Geometry(
(
ST_Dump(
ST_CollectionExtract(
ST_VoronoiPolygons(
ST_SnapToGrid(
ST_Collect(point),
pow(2.0, -8)
),
0.0
),
3
)
)
).geom
) AS poly
FROM cell_point_tmp;
Thanks again!
Jim
--
J.J. Green
http://soliton.vm.bytemark.co.uk/pub/jjg/en/
More information about the postgis-users
mailing list