Name

ST_LineToCurve — Converts a linear geometry to a curved geometry.

Synopsis

geometry ST_LineToCurve(geometry geomANoncircular);

Description

Converts plain LINESTRING/POLYGON to CIRCULAR STRINGs and Curved Polygons. Note much fewer points are needed to describe the curved equivalent.

[Note]

If the input LINESTRING/POLYGON is not curved enough to clearly represent a curve, the function will return the same input geometry.

Availability: 1.3.0

This function supports 3d and will not drop the z-index.

This method supports Circular Strings and Curves.

Examples

This example converts a linear Polygon approximating a circle to a CurvePolygon.

Code
WITH data AS (
    SELECT ST_Buffer('POINT(1 3)'::geometry, 3) AS geom
)
SELECT geom AS "input_Linear polygon",
       ST_LineToCurve(geom) AS "Curved polygon"
FROM data;
Output
-[ RECORD 1 ]----------
input_Linear polygon | POLYGON((4 3,3.942 2.415,3.772 1.852,3.494 1.333,3.121 0.879,2.667 0.506,2.148 0.228,1.585 0.058,1 0,0.415 0.058,-0.148 0.228,-0.667 0.506,-1.121 0.879,-1.494 1.333,-1.772 1.852,-1.942 2.415,-2 3,-1.942 3.585,-1.772 4.148,-1.494 4.667,-1.121 5.121,-0.667 5.494,-0.148 5.772,0.415 5.942,1 6,1.585 5.942,2.148 5.772,2.667 5.494,3.121 5.121,3.494 4.667,3.772 4.148,3.942 3.585,4 3))
Curved polygon       | CURVEPOLYGON(CIRCULARSTRING(4 3,-2 3,4 3))
Figure
Geometry figure for visual-st-linetocurve-01

This example converts a 3D linear ring to a CircularString while preserving Z.

Code
WITH data AS (
    SELECT ST_Translate(
        ST_Force3D(ST_Boundary(ST_Buffer(ST_Point(1, 3), 2, 2))),
        0, 0, 3
    ) AS geom
)
SELECT geom AS "input_Linear ring at Z=3",
       ST_LineToCurve(geom) AS "Circular string at Z=3"
FROM data;
Output
-[ RECORD 1 ]----------
input_Linear ring at Z=3 | LINESTRING Z (3 3 3,2.414 1.586 3,1 1 3,-0.414 1.586 3,-1 3 3,-0.414 4.414 3,1 5 3,2.414 4.414 3,3 3 3)
Circular string at Z=3   | CIRCULARSTRING Z (3 3 3,-1 3 3,3 3 3)
Figure
Geometry figure for visual-st-linetocurve-02

See Also

ST_CurveToLine