ST_NPoints

更新时间:
复制 MD 格式

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

ParameterDescription
g1The 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)