Name

ST_EndPoint — Returns the last point of a LineString, CircularLineString, or NURBSCurve.

Synopsis

geometry ST_EndPoint(geometry g);

Description

Returns the last point of a LINESTRING, CIRCULARLINESTRING, or NURBSCURVE geometry as a POINT. Returns NULL if the input is not a LINESTRING, CIRCULARLINESTRING, or NURBSCURVE.

This method implements the SQL/MM specification. SQL-MM 3: 7.1.4

This function supports 3d and will not drop the z-index.

This method supports Circular Strings and Curves.

Changed: 2.0.0 no longer works with single geometry MultiLineStrings. In older versions of PostGIS a single-line MultiLineString would work with this function and return the end point. In 2.0.0 it returns NULL like any other MultiLineString. The old behavior was an undocumented feature, but people who assumed they had their data stored as LINESTRING may experience these returning NULL in 2.0.0.

Examples

End point of a LineString

Code
SELECT ST_EndPoint('LINESTRING(1 1,2 2,3 3)'::geometry);
Output
POINT(3 3)
Figure
Geometry figure for visual-st-endpoint-01

End point of a non-LineString is NULL

Code
SELECT ST_EndPoint('POINT(1 1)'::geometry) IS NULL AS is_null;
Output
t

End point of a 3D LineString

3D endpoint.

Code
SELECT ST_EndPoint('LINESTRING(1 1 2,1 2 3,0 0 5)');
Output
POINT(0 0 5)
Figure
Geometry figure for visual-st-endpoint-03

End point of a CircularString

Code
SELECT ST_EndPoint('CIRCULARSTRING(5 2,-3 2,-2 1,-4 2,6 3)'::geometry);
Output
POINT(6 3)
Figure
Geometry figure for visual-st-endpoint-04

End point of a NURBSCurve

Code
SELECT ST_EndPoint('NURBSCURVE(2, (0 0, 1 1, 2 0))'::geometry);
Output
POINT(2 0)
Figure
Geometry figure for visual-st-endpoint-05