Fork me on GitHub

ST_NPoints

Signature

INT ST_NPoints(GEOMETRY geom);

Description

Returns the number of points (vertexes) in a geometry (geom).

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

Examples

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

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

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

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

SELECT ST_NPoints('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