PostGISGeometry Editors

ST_LineToCurve

What is ST_LineToCurve?

ST_LineToCurve inspects a straight-segment geometry and tries to reconstruct any circular arcs it contains, returning a curve-typed geometry (CIRCULARSTRING, COMPOUNDCURVE, or CURVEPOLYGON).

SQL
ST_LineToCurve(geometry geom)geometry

The conversion is heuristic — sequences of segments that closely follow an arc are collapsed into a CIRCULARSTRING. If no arcs are detected the input is returned in its equivalent curve-typed wrapper.

When would you use ST_LineToCurve?

Use ST_LineToCurve when importing data that was originally modelled with curves but was linearised for a particular exchange format. Reconstructing the curves restores intent, reduces vertex count, and makes downstream editing workflows more natural.

It is also useful when modelling road geometries from DGN or CAD sources — curved alignments are more accurately represented as COMPOUNDCURVE than as dense polylines.

FAQs

How does ST_LineToCurve detect arcs?

It fits groups of consecutive vertices to a circle within a tolerance. Straight runs are preserved as inner LINESTRING components of a COMPOUNDCURVE.

Is the conversion lossless?

Only if the input was produced from a true circular arc and the vertex count is large enough to fit a circle reliably. Sparse or noisy input may fail to round-trip cleanly.

What happens if no arcs are found?

The geometry is returned wrapped in the equivalent curve type (e.g. LINESTRINGCOMPOUNDCURVE) but without inner CIRCULARSTRING components.

How does it differ from ST_CurveToLine?

ST_CurveToLine goes the other direction — it strokes curves into straight segments. Both functions are inverses, but the pair is lossy unless tolerances are set carefully.