[postgis-users] ST_Buffer on a point can generate an extra vertex

Bruce Rindahl bruce.rindahl at gmail.com
Fri Dec 11 14:09:34 PST 2020


I have been using PostGIS to generate mathematical diagrams.  One of the
first things I needed was a table of points evenly spaced around a circle.
This seemed easy to do using ST_Buffer and exploding  the geometry with
ST_DumpPoints to get what I needed.  I came up with this:


WITH pts AS (

         SELECT st_dumppoints.path,     st_dumppoints.geom

           FROM st_dumppoints(st_buffer(st_geomfromtext('POINT(0 0)'),
(100), 12)) st_dumppoints(path, geom)

        )

 SELECT pts.path[2] AS path,  st_x(pts.geom) AS x, st_y(pts.geom) AS y,
pts.geom   FROM pts


This was intended to get 48 points (12*4) evenly spaced around a point at
(0.0) with a radius of 100.  The query above gives 49 points which makes
sense (the starting point is duplicated).  However, if you increase the
parameter to 13, you get 54 points instead of the expected 53.  The last
few lines of the above query using 13 is:


52 99.27088740980523 12.053668025533685
"0101000000BE80253856D1584022041D607A1B2840"
53 100 1.445577598596648e-12 "01010000000000000000005940000000804D6E793D"
54 100 0 "010100000000000000000059400000000000000000"


The buffer operation is generating an extra vertex & a segment with a
length of  1.445577598596648e-12.

Using 14 for the parameter gives 57 points as expected, but every other
parameter greater than 14 gives the extra point.  I am not sure this
qualifies as a bug but an extra tiny segment might cause issues with
intersections and is_valid.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20201211/911755b4/attachment.html>


More information about the postgis-users mailing list