Skip to content

ST_NPOINTS

Returns the number of points in a GEOGRAPHY object.

Note: For polygons, the start and end points are counted separately, even if they represent the same location. For example, a triangle would have 4 points in total because it closes back to its starting point.

Syntax

sql
ST_NPOINTS(<input>)

Arguments

  • <input>: The GEOGRAPHY object

Returns

Returns an INTEGER representing the total number of points in the input GEOGRAPHY.

Examples

sql
SELECT ST_NPOINTS('LINESTRING(0 0, 1 1, 2 2)'::GEOGRAPHY);
-- 3

SELECT ST_NPOINTS('POLYGON((0 0, 1 1, 2 0, 0 0))'::GEOGRAPHY);
-- 4