ST_DumpPoints

更新时间:
复制 MD 格式

Returns every vertex of a geometry as a set of geometry_dump rows, each containing a point geometry and a path array that identifies its position in the input.

Syntax

geometry_dump[] ST_DumpPoints(geometry geom);

Parameters

ParameterDescription
geomThe input geometry.

Return value

Each returned geometry_dump row contains two fields:

FieldDescription
geomA Point geometry representing one vertex of the input.
pathAn integer array encoding the position of the vertex within the input geometry.

Path encoding by geometry type

The structure of the path array depends on the type of the input geometry:

  • LineString{i}, where i is the 1-based index of the point within the line.

  • Polygon{i, j}, where i is the 1-based index of the ring (1 = outer ring) and j is the 1-based index of the point within that ring.

Usage notes

ST_DumpPoints supports the following geometry types in addition to basic 2D geometries:

  • Circular strings and curves

  • Polyhedral surfaces

  • Triangles and triangulated irregular network (TIN) surfaces

  • 3D objects

Examples

The following query dumps all vertices of a MULTILINESTRING containing two line segments and shows the path index for each point.

SELECT (t.dump).path, ST_AsText((t.dump).geom)
FROM (
    SELECT ST_DumpPoints('MULTILINESTRING((0 0,0 2),(0 1,0 3))'::geometry) AS dump
) AS t;

Output:

 path  | st_astext
-------+------------
 {1,1} | POINT(0 0)
 {1,2} | POINT(0 2)
 {2,1} | POINT(0 1)
 {2,2} | POINT(0 3)
(4 rows)

The path {1,1} identifies the first point of the first line; {2,2} identifies the second point of the second line.