ST_NurbsToLineString — Converts a NURBS curve to a LINESTRING by uniform sampling.
geometry ST_NurbsToLineString(geometry nurbscurve, integer num_segments=32);
Converts a NURBS curve to a LINESTRING geometry by creating a piecewise linear approximation. The curve is sampled at uniformly distributed parameter values and the resulting points are connected with straight line segments.
The optional num_segments parameter specifies the number of line segments in the output (default: 32, range: 2-10000). Higher values produce smoother approximations but increase geometry complexity.
Raises an error if the input is not a NURBS curve. Returns NULL if the input is NULL.
Availability: 3.7.0
This example converts a NURBS curve to a LineString using the default quality.
SELECT ST_NurbsToLineString('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry);
LINESTRING(0 0,0.3125 0.60546875,0.625 1.171875,0.9375 1.69921875,1.25 2.1875,1.5625 2.63671875,1.875 3.046875,2.1875 3.41796875,2.5 3.75,2.8125 4.04296875,3.125 4.296875,3.4375 4.51171875,3.75 4.6875,4.0625 4.82421875,4.375 4.921875,4.6875 4.98046875,5 5,5.3125 4.98046875,5.625 4.921875,5.9375 4.82421875,6.25 4.6875,6.5625 4.51171875,6.875 4.296875,7.1875 4.04296875,7.5 3.75,7.8125 3.41796875,8.125 3.046875,8.4375 2.63671875,8.75 2.1875,9.0625 1.69921875,9.375 1.171875,9.6875 0.60546875,10 0)
This example creates a high-quality approximation with 64 segments.
SELECT ST_NurbsToLineString('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry, 64);
LINESTRING(0 0,0.15625 0.3076171875,0.3125 0.60546875,0.46875 0.8935546875,0.625 1.171875,0.78125 1.4404296875,0.9375 1.69921875,1.09375 1.9482421875,1.25 2.1875,1.40625 2.4169921875,1.5625 2.63671875,1.71875 2.8466796875,1.875 3.046875,2.03125 3.2373046875,2.1875 3.41796875,2.34375 3.5888671875,2.5 3.75,2.65625 3.9013671875,2.8125 4.04296875,2.96875 4.1748046875,3.125 4.296875,3.28125 4.4091796875,3.4375 4.51171875,3.59375 4.6044921875,3.75 4.6875,3.90625 4.7607421875,4.0625 4.82421875,4.21875 4.8779296875,4.375 4.921875,4.53125 4.9560546875,4.6875 4.98046875,4.84375 4.9951171875,5 5,5.15625 4.9951171875,5.3125 4.98046875,5.46875 4.9560546875,5.625 4.921875,5.78125 4.8779296875,5.9375 4.82421875,6.09375 4.7607421875,6.25 4.6875,6.40625 4.6044921875,6.5625 4.51171875,6.71875 4.4091796875,6.875 4.296875,7.03125 4.1748046875,7.1875 4.04296875,7.34375 3.9013671875,7.5 3.75,7.65625 3.5888671875,7.8125 3.41796875,7.96875 3.2373046875,8.125 3.046875,8.28125 2.8466796875,8.4375 2.63671875,8.59375 2.4169921875,8.75 2.1875,8.90625 1.9482421875,9.0625 1.69921875,9.21875 1.4404296875,9.375 1.171875,9.53125 0.8935546875,9.6875 0.60546875,9.84375 0.3076171875,10 0)
This example creates a lower-quality, faster approximation with 16 segments.
SELECT ST_NurbsToLineString('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry, 16);
LINESTRING(0 0,0.625 1.171875,1.25 2.1875,1.875 3.046875,2.5 3.75,3.125 4.296875,3.75 4.6875,4.375 4.921875,5 5,5.625 4.921875,6.25 4.6875,6.875 4.296875,7.5 3.75,8.125 3.046875,8.75 2.1875,9.375 1.171875,10 0)