ST_Points

更新时间:
复制 MD 格式

Returns a MultiPoint geometry containing all vertices of a geometry.

Syntax

geometry ST_Points(geometry geom)

Parameters

ParameterDescription
geomThe input geometry.

Description

ST_Points extracts every vertex from a geometry and returns them as a MultiPoint.

`ST_Points` preserves duplicate vertices. For circular geometry objects, the start point and end point both appear in the result. To remove duplicate vertices, use ST_RemoveRepeatedPoints.

M and Z coordinates are preserved. If the input geometry has M or Z coordinates, the returned MultiPoint retains them.

ST_Points supports circular strings and curves.

Examples

Extract vertices from a 3D polygon

The following example demonstrates two key behaviors: Z coordinate preservation and duplicate vertex retention for a closed geometry.

SELECT ST_AsText(ST_Points('POLYGON Z ((30 10 4, 10 30 5, 40 40 6, 30 10 4))'::geometry));

Result:

MULTIPOINT Z ((30 10 4),(10 30 5),(40 40 6),(30 10 4))

The start point (30 10 4) appears twice — once at the start and once at the end — because ST_Points does not remove duplicate vertices.

Extract vertices from a line

SELECT ST_AsText(ST_Points('LINESTRING(0 0, 2 2)'::geometry));

Result:

MULTIPOINT(0 0,2 2)