ST_Line_Interpolate_Point — Returns the Coordinates for the point on the line at the given fraction. This fraction, is applied to the line's total length.
geometry
ST_Line_Interpolate_Point(
bytea
Geometry, double
fraction)
;
Returns the Coordinates for the point on the line at the given fraction. This fraction, is applied to the line's total length.
The Geometry object must be a LineString or MultiLineString. The second parameter represents the fraction of the Line where the point will be located. If the index is out of range[0-1] the first or last point on the line will be returned. The Z and M cooordinates of the computed point will be interpolated from the line segment containing it, if they exist.
2D | 3D | M |
---|---|---|
OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006) | SQL-MM Part 3 |
---|---|---|---|
- | - | - | - |
--2D LineString (Point at 80% along Line) SELECT ST_AsEWKT(ST_Line_Interpolate_Point(ST_GeomFromEWKT('SRID=25830;LINESTRING (17 21, 26 39, 44 46)'),0.8)); --Result SRID=25830;POINT (36.64875355835534 43.14118193936041) --3D LineString (Point at 20% along Line) SELECT ST_AsEWKT(ST_Line_Interpolate_Point(ST_GeomFromEWKT('LINESTRING (17 21 15, 26 39 20, 44 46 25)'),0.2)); --Result POINT (20.527425830535137 28.05485166107027 16.959681016963962) --2D LineString (Point at 120% along Line. It returns the last vertex of the line) SELECT ST_AsEWKT(ST_Line_Interpolate_Point(ST_GeomFromText('LINESTRING (17 21, 26 39, 44 46)'),1.2)); --Result POINT (44 46) --2D LineString (Point at 10 meters in Line) SELECT ST_ASEWKT(ST_Line_Interpolate_Point(line,fraction)) FROM (SELECT 10/ST_Length(line) as fraction,line FROM (SELECT ST_GeomFromEWKT('SRID=25830;LINESTRING (17 21, 26 39, 44 46)') as line) as foo) as b; --Result SRID=25830;POINT (21.47213595499958 29.94427190999916)
Point at 80% along Line |