[postgis-users] ST_CurveToLine and ST_LineToCurve problems

Bruce Rindahl bruce.rindahl at gmail.com
Fri Nov 12 13:47:23 PST 2021


As Paul mentioned, this has been an issue for a while.  I ran into this
when I needed to precisely divide a circle into a specified number of
points.
I finally had to generate the points directly.  To get a table of points
precisely spaced around a circle:

with
parameters as (
select 101.0 as num_points, 100.0 as radius
),
points as (
select generate_series(1,parameters.num_points) as angle from parameters
),
coordinates as (
select row_number() over (order by angle), angle,
cos(angle / parameters.num_points * pi() * 2) * parameters.radius as x,
sin(angle / parameters.num_points * pi() * 2) * parameters.radius as y
from points,parameters
)
select row_number,st_MakePoint(x,y) from coordinates

Specify the num_points and radius of the circle on the third line.

The points are in order so you can stitch them together for a perfectly
segmented line.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20211112/b182c1cb/attachment.html>


More information about the postgis-users mailing list