The ST_EndPoint() function

The ST_EndPoint() function returns the last point of a linestring.

Syntax

ST_EndPoint(ln1 ST_LineString)

Return type

ST_Point

Example

The endpoint_test table stores the gid INTEGER column, which uniquely identifies each row and the ln1 ST_LineString column that stores linestrings:
CREATE TABLE endpoint_test (gid integer,
                            ln1 ST_LineString);
The following INSERT statements insert linestrings into the endpoint_test table. The first linestring does not have Z coordinates or measures, while the second one does:
INSERT INTO endpoint_test VALUES( 
   1, 
   ST_LineFromText('linestring (10.02 20.01,23.73 21.92,30.10 40.23)',1000)
);

INSERT INTO endpoint_test VALUES( 
   2, 
   ST_LineFromText('linestring zm (10.02 20.01 5.0 7.0,23.73 21.92
6.5 7.1,30.10 40.23 6.9 7.2)',1000) 
);
The following query lists the gid column with the output of the ST_EndPoint() function. The ST_EndPoint() function generates an ST_Point geometry:
SELECT gid, ST_EndPoint(ln1) Endpoint 
   FROM endpoint_test;


gid       1
endpoint  1000 POINT (30.1 40.23) 

gid       2
endpoint  1000 POINT ZM (30.1 40.23 6.9 7.2) 

See also

The ST_StartPoint() function