PostgreSQL npoints() Function
The PostgreSQL npoints()
function counts the number of points on the specified path or polygon and returns it.
npoints()
Syntax
This is the syntax of the PostgreSQL npoints()
function:
npoints(geometric_type) -> integer
Parameters
geometric_type
-
Required. It can be a polygon
polygon
or a pathpath
.
Return value
The PostgreSQL npoints()
function returns the number of points on the path or polygon specified by the parameter.
npoints()
Examples
The following statement shows how to use PostgreSQL npoints()
function to count the number of points on the open path path '[(2,0),(0,0)]'
.
SELECT npoints(path '[(2,0),(0,0)]');
npoints
---------
2
The following statement shows how to use PostgreSQL npoints()
function to count the number of points on the close path path '((2,0),(0,0))'
.
SELECT npoints(path '((2,0),(0,0))');
npoints
--------
2
The following statement shows how to use PostgreSQL npoints()
function to count the number of points on polygon polygon '(0,0),(2,2),(4,0)'
.
SELECT npoints(polygon '(0,0),(2,2),(4,0)');
npoints
---------
3