ST_NumPoints()

TL;DR

Use ST_NumPoints() to count the points in a LINESTRING.

Returns the number of points in a line geometry.

Syntax

ST_NumPoints(geom)

Arguments

Argument

Description

geom

A GEOMETRY or GEOMETRY32 line value.

Return Value

Returns int64.

Usage Notes

Examples

DROP DATABASE IF EXISTS geo_accessor_demo;
CREATE DATABASE geo_accessor_demo;
USE geo_accessor_demo;
SELECT ST_NumPoints(ST_GeomFromText('LINESTRING(0 0,1 1,2 2)')) AS point_count;
DROP DATABASE geo_accessor_demo;

See Also

ST_PointN, ST_IsClosed