PostGISGeometry Accessors

ST_StartPoint

What is ST_StartPoint?

ST_StartPoint is a PostGIS function that returns the first point of a LINESTRING (or CIRCULARSTRING) as a POINT geometry. For non-line input it returns NULL in standard PostGIS.

SQL
ST_StartPoint(geometry line)geometry

SRID and dimensionality are preserved. Newer PostGIS versions may handle single-component MULTILINESTRING.

When would you use ST_StartPoint?

Use ST_StartPoint to grab the origin vertex of a line for O/D analysis, snapping, or connectivity checks:

SQL
1SELECT id,
2       ST_StartPoint(route_geom) AS origin,
3       ST_EndPoint(route_geom)   AS destination,
4       ST_Distance(ST_StartPoint(route_geom)::geography,
5                   ST_EndPoint(route_geom)::geography) AS od_distance_m
6FROM trips;

Pair with ST_EndPoint for O/D pairs, or with ST_ClosestPoint/ST_Snap to align endpoints to a node network.

FAQs

What does ST_StartPoint return for a MultiLineString?

NULL in standard PostGIS. Unpack with ST_GeometryN(geom, 1) first, or use ST_LineMerge if the components form a single connected chain.

Does ST_StartPoint preserve Z and M?

Yes. The returned point carries the full dimensionality of the source line's first vertex.

What is ST_StartPoint on a closed line?

Numerically equal to ST_EndPoint — a closed ring's first and last points match by definition.

Why is ST_StartPoint returning NULL?

Almost always because the input is a MULTILINESTRING or a non-line type. Check GeometryType(geom).