Categories:

Geospatial Functions

# ST_NPOINTS , ST_NUMPOINTS¶

Returns the number of points in a GEOGRAPHY object.

## Syntax¶

ST_NPOINTS( <geography_expression_1> )


## Arguments¶

geography_expression_1

The argument must be an expression of type GEOGRAPHY.

## Returns¶

Returns a value of type INTEGER.

## Usage Notes¶

• Each Polygon loop lists the starting point twice (once as the start, once as the end). ST_NPOINTS counts both occurrences. For example, given a triangular Polygon, ST_NPOINTS returns 4, not 3.

• ST_NUMPOINTS is an alias for ST_NPOINTS.

Note

In some other systems, ST_NUMPOINTS behaves differently from ST_NPOINTS and returns the number of points for LineString / MultiLineString objects only.

## Examples¶

This shows the number of points in a simple Polygon.

create table geospatial_table_01 (g1 GEOGRAPHY, g2 GEOGRAPHY);
insert into geospatial_table_01 (g1, g2) values
('POLYGON((0 0, 3 0, 3 3, 0 3, 0 0))', 'POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))');

SELECT ST_NPOINTS(g1)
FROM geospatial_table_01;
+----------------+
| ST_NPOINTS(G1) |
|----------------|
|              5 |
+----------------+