Skip to main content
Returns a line at a given offset distance from a linear geometry. If the distance is positive, the offset is on the left side of the input line; if it is negative, it is on the right side. Returns null for empty geometries. The optional third parameter quadrantSegments controls the number of line segments used to approximate a quarter circle at round joins. The default value is 8.

Signatures

ST_OffsetCurve(geometry: Geometry, distance: Double)
ST_OffsetCurve(geometry: Geometry, distance: Double, quadrantSegments: Integer)

Parameters

geometry
Geometry
required
The linear geometry to offset.
distance
Double
required
The offset distance. Positive offsets to the left of the line; negative to the right.
quadrantSegments
Integer
The number of segments used to approximate a quarter circle at round joins. Defaults to 8.

Return type

The offset line.

Example

ST_OffsetCurve with a positive offset
SELECT ST_AsText(ST_OffsetCurve(ST_GeomFromWKT('LINESTRING(0 0, 10 0, 10 10)'), 5.0))
LINESTRING (0 5, 5 5, 5 10)
With a negative distance (offset to the right): ST_OffsetCurve with a negative offset
SELECT ST_NPoints(ST_OffsetCurve(ST_GeomFromWKT('LINESTRING(0 0, 10 0, 10 10)'), -3.0))
11
With quadrantSegments set to 16: ST_OffsetCurve with quadrantSegments
SELECT ST_NPoints(ST_OffsetCurve(ST_GeomFromWKT('LINESTRING(0 0, 10 0, 10 10)'), -3.0, 16))
19