ST_NumPoints¶
Returns the number of points of a linestring geometry or geography.
Usage¶
integer ST_NumPoints(geom: geometry)
integer ST_NumPoints(geog: geography)
Arguments¶
- geog (geography): Input geography
- geom (geometry): Input geometry
Description¶
Returns the total number of coordinate points in a linestring geometry.
Returns NULL for other geometry types. Use ST_NPoints() to calculate
the number of vertices for all geometry types.
Examples¶
SELECT ST_NumPoints(
ST_GeomFromWKT('LINESTRING (1 2, 3 4, 5 6)')
);
┌──────────────────────────────────────────────────────────────────┐
│ st_numpoints(st_geomfromwkt(Utf8("LINESTRING (1 2, 3 4, 5 6)"))) │
│ int32 │
╞══════════════════════════════════════════════════════════════════╡
│ 3 │
└──────────────────────────────────────────────────────────────────┘
SELECT ST_NumPoints(
ST_GeomFromWKT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))')
);
┌───────────────────────────────────────────────────────────────────────────┐
│ st_numpoints(st_geomfromwkt(Utf8("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))"))) │
│ int32 │
╞═══════════════════════════════════════════════════════════════════════════╡
│ │
└───────────────────────────────────────────────────────────────────────────┘
SELECT ST_NumPoints(
ST_GeogFromWKT('LINESTRING (1 2, 3 4, 5 6)')
);
┌──────────────────────────────────────────────────────────────────┐
│ st_numpoints(st_geogfromwkt(Utf8("LINESTRING (1 2, 3 4, 5 6)"))) │
│ int32 │
╞══════════════════════════════════════════════════════════════════╡
│ 3 │
└──────────────────────────────────────────────────────────────────┘
SELECT ST_NumPoints(
ST_GeogFromWKT('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))')
);
┌───────────────────────────────────────────────────────────────────────────┐
│ st_numpoints(st_geogfromwkt(Utf8("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))"))) │
│ int32 │
╞═══════════════════════════════════════════════════════════════════════════╡
│ │
└───────────────────────────────────────────────────────────────────────────┘