Fork me on GitHub

ST_NumPoints

Signature

INT ST_NumPoints(GEOMETRY geom);

Description

Returns the number of points in geom.

Implements the OpenGIS Simple Features Implementation Specification for SQL version 1.2.1.

Examples

SELECT ST_NumPoints('POINT(2 2)');
-- Answer: 1

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

-- ST_NumPoints includes duplicate points in the count.
SELECT ST_NumPoints('MULTIPOINT(2 2, 4 4, 4 4)');
-- Answer: 3

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

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: 15
See also