Name
ST_NPoints, st_npoints, ST_PointN, st_pointn — count and access the vertices of a linear geometry
Synopsis
integer ST_NPoints(
|
in geom any); |
any ST_PointN(
|
in geom any, |
in n integer); |
Description
ST_NPoints returns the number of vertices in
geom. For a POINT the result is 1; for a
LINESTRING, ARCSTRING, RING or POINTLIST the result is the count of
constituent points; for other geometry kinds the result follows the
underlying point-array length.
ST_PointN returns the n -th
vertex of geom as a POINT, preserving the Z and M
coordinates of the source if present. n is 1-based;
negative indices count from the end (-1 is the last vertex). The function
applies to LINESTRING, ARCSTRING, POINTLIST and RING geometries; for other
types it returns NULL.
An out-of-range index raises SQL error 22023 with hint
GEO.. listing the valid index ranges.