ST_CurveToLine
What is ST_CurveToLine?
ST_CurveToLine "strokes" a curved geometry — CIRCULARSTRING, COMPOUNDCURVE, CURVEPOLYGON, or MULTICURVE — into a straight-segment approximation as a LINESTRING, POLYGON, or MULTI* geometry.
1ST_CurveToLine(geometry curveGeom) → geometry
2ST_CurveToLine(geometry curveGeom, float tolerance, integer tolerance_type, integer flags) → geometrytolerance_type selects the interpretation: 0 = maximum segment length (default), 1 = maximum deviation from curve, 2 = maximum angle between segments. flags controls symmetric output and preserved angle. Available from PostGIS 1.3; tolerance-typed variant added in 2.3.
When would you use ST_CurveToLine?
Use ST_CurveToLine before exporting curved geometry to formats or clients that do not support circular arcs — GeoJSON, shapefiles, MapLibre/MapBox vector tiles, and most web mapping clients only handle straight segments. It is also a prerequisite for most spatial predicates, since ST_Intersects, ST_Buffer, and similar functions operate on linear geometry.
Setting tolerance_type = 1 with a small metric tolerance produces a visually smooth approximation for cartographic output, while tolerance_type = 2 is useful when a known maximum angular step is required.
FAQs
What is the default tolerance?
The single-argument form uses 32 segments per quadrant. The three-argument form defaults to tolerance_type = 0 (maximum segment length) with the supplied value in CRS units.
Does ST_CurveToLine preserve Z and M values?
Yes. Z and M ordinates are linearly interpolated along the generated segments.
Can I recover the original curve after calling ST_CurveToLine?
Only approximately — use ST_LineToCurve to detect arcs in a dense LineString and rebuild CIRCULARSTRING segments. Round-tripping is lossy because the approximation tolerance has already been baked in.
Why do overlay operations silently call ST_CurveToLine?
GEOS, the library behind most overlay predicates, does not handle curves natively. PostGIS automatically linearises curves before overlay, then re-wraps the result. If you pass a tight tolerance explicitly with ST_CurveToLine first, you can control the fidelity rather than relying on the default.