Returns the number of vertices in a geometry object. Supports all geometry types, including 3D objects and curves.
Syntax
integer ST_NPoints(geometry g1)Parameters
| Parameter | Description |
|---|---|
g1 | The geometry object to query. |
Supported geometry types
ST_NPoints works with all geometry types, including:
Circular strings
Curves
Polyhedral surfaces
3D objects
Examples
Count the vertices in a 2D polygon:
SELECT ST_NPoints('POLYGON((0 0,0 1,1 1,0 0))'::geometry);
st_npoints
------------
4
(1 row)该文章对您有帮助吗?