Fork me on GitHub

ST_NumPoints

Signature

INT ST_NumPoints(GEOMETRY linestring);

Description

Returns the number of points in a linestring.

With other dimensions (points and polygons) or multigeometries, ST_NumPoints will return a NULL value.

Implements the OpenGIS Simple Features Implementation Specification for SQL version 1.2.1.
Implements the SQL/MM specification. SQL-MM 3: 7.2.4

Examples

SELECT ST_NumPoints('LINESTRING(2 2, 4 4)');
-- Answer: 2

-- ST_NumPoints includes duplicate points in the count.
SELECT ST_NumPoints('LINESTRING(2 2, 4 4, 6 6, 6 6)');
-- Answer: 4
Where ST_NumPoints returns NULL
SELECT ST_NumPoints('POINT(2 2)');
-- Answer: NULL

SELECT ST_NumPoints('MULTIPOINT(2 2, 4 4)');
-- Answer: NULL

SELECT ST_NumPoints('MULTILINESTRING((2 2, 4 4), (3 1, 6 3))');
-- Answer: NULL

SELECT ST_NumPoints('POLYGON((0 0, 10 0, 10 6, 0 6, 0 0),
                             (1 1, 2 1, 2 5, 1 5, 1 1),
                             (8 5, 8 4, 9 4, 9 5, 8 5))');
-- Answer: NULL
See also