The ST_StartPoint() function

The ST_StartPoint() function returns the first point of a linestring.

Syntax

ST_StartPoint(ln1 ST_LineString)

Return type

ST_Point

Example

The startpoint_test table is created with the gid INTEGER column, which uniquely identifies the rows of the table, and the ln1 ST_LineString column:
CREATE TABLE startpoint_test (gid integer,
                              ln1 ST_LineString);
The following INSERT statements insert the ST_LineStrings into the ln1 column. The first ST_LineString does not have Z coordinates or measures, while the second ST_LineString has both:
INSERT INTO startpoint_test VALUES( 
   1, 
   ST_LineFromText('linestring (10.02 20.01,23.73 21.92,30.10 40.23)', 1000) 
);

INSERT INTO startpoint_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 ST_StartPoint() function extracts the first point of each ST_LineString. The first point in the list does not have a Z coordinate or a measure, while the second point has both because the source linestring does:
SELECT gid, ST_StartPoint(ln1) Startpoint 
   FROM startpoint_test;


gid         1
startpoint  1000 POINT (10.02 20.01) 

gid         2
startpoint  1000 POINT ZM (10.02 20.01 5 7) 

See also

The ST_EndPoint() function