ST_NPoints¶
Returns the number of points of the geometry or geography.
Usage¶
integer ST_NPoints(geom: geometry)
integer ST_NPoints(geog: geography)
Arguments¶
- geog (geography): Input geography
- geom (geometry): Input geometry
Description¶
Returns the total number of coordinate points in the geometry, counting all vertices across all components.
Examples¶
SELECT ST_NPoints(
ST_GeomFromWKT('LINESTRING (1 2, 3 4, 5 6)')
);
┌────────────────────────────────────────────────────────────────┐
│ st_npoints(st_geomfromwkt(Utf8("LINESTRING (1 2, 3 4, 5 6)"))) │
│ uint64 │
╞════════════════════════════════════════════════════════════════╡
│ 3 │
└────────────────────────────────────────────────────────────────┘
SELECT ST_NPoints(
ST_GeomFromWKT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))')
);
┌─────────────────────────────────────────────────────────────────────────┐
│ st_npoints(st_geomfromwkt(Utf8("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))"))) │
│ uint64 │
╞═════════════════════════════════════════════════════════════════════════╡
│ 5 │
└─────────────────────────────────────────────────────────────────────────┘
SELECT ST_NPoints(
ST_GeogFromWKT('LINESTRING (1 2, 3 4, 5 6)')
);
┌────────────────────────────────────────────────────────────────┐
│ st_npoints(st_geogfromwkt(Utf8("LINESTRING (1 2, 3 4, 5 6)"))) │
│ uint64 │
╞════════════════════════════════════════════════════════════════╡
│ 3 │
└────────────────────────────────────────────────────────────────┘
SELECT ST_NPoints(
ST_GeogFromWKT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))')
);
┌─────────────────────────────────────────────────────────────────────────┐
│ st_npoints(st_geogfromwkt(Utf8("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))"))) │
│ uint64 │
╞═════════════════════════════════════════════════════════════════════════╡
│ 5 │
└─────────────────────────────────────────────────────────────────────────┘