PostGISGeometry Processing

ST_OffsetCurve

What is ST_OffsetCurve?

ST_OffsetCurve is a PostGIS function that returns a line offset to one side of the input LineString by the given distance. Positive distances offset to the left of the line direction, negative distances to the right. Style parameters control how corners are rendered.

SQL
ST_OffsetCurve(geometry line, float signed_distance, text style_parameters = '')geometry

style_parameters is a space-delimited string with keys like quad_segs=8, join=round|mitre|bevel, and mitre_limit=5.0.

When would you use ST_OffsetCurve?

Use ST_OffsetCurve to create parallel lines alongside linear features — carriageway edges alongside a road centreline, canal banks along a waterway, or setback lines along a property boundary. It is also a building block for producing one-sided buffers that don't wrap around line endpoints.

SQL
1SELECT road_id,
2       ST_OffsetCurve(geom, 3.0, 'quad_segs=8 join=round') AS left_edge,
3       ST_OffsetCurve(geom, -3.0, 'quad_segs=8 join=round') AS right_edge
4FROM road_centrelines;

FAQs

How does this differ from ST_Buffer with side=left?

ST_Buffer with a side parameter produces a polygonal buffer on one side of a line. ST_OffsetCurve produces a single parallel line — just a curve, not an area. Use offset curves for linear output (carriageway edges, shifted centrelines) and side buffers for polygonal output (lanes, corridors).

What do the style parameters do?

quad_segs controls the number of segments per quarter circle at rounded corners (default 8). join=round|mitre|bevel selects the corner style. mitre_limit (default 5) caps the length of sharp mitre joins to prevent spikes at acute angles.

What happens at self-intersections?

At tight bends or self-crossings the offset curve can become multi-part or reversed. Inspect results on curved or zig-zagging inputs, and consider simplifying the input first to remove tiny segments that produce offset artefacts.

What units is the distance in?

The distance is in the units of the input's SRID — metres for most projected CRSs, degrees for geographic CRSs like EPSG:4326. For metre-accurate offsets on lat/lon data, reproject to a local projected CRS first.