ST_DumpRings

更新时间:
复制 MD 格式

Extracts the outer ring and inner rings of a polygon as individual rows.

Syntax

geometry_dump[] ST_DumpRings(geometry aPolygon)

Parameters

ParameterDescription
aPolygonThe polygon to extract rings from.

Description

ST_DumpRings returns a set of geometry_dump rows. Each row contains two fields:

  • path: An integer array indicating the ring index. {0} identifies the outer ring; {1}, {2}, and so on identify inner rings in order.

  • geom: The ring represented as a polygon object.

Limitations:

  • Accepts only Polygon objects. MultiPolygon is not supported.

  • Supports 3D objects.

Examples

Extract rings from an inline polygon

The following example extracts the outer ring and one inner ring from a polygon with a hole:

SELECT (t.dump).path,ST_AsText((t.dump).geom) from (select ST_DumpRings('POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,2 1,2 2,1 2,1 1))'::geometry) as dump) as t;
 path |           st_astext
------+--------------------------------
 {0}  | POLYGON((0 0,0 4,4 4,4 0,0 0))
 {1}  | POLYGON((1 1,2 1,2 2,1 2,1 1))
(2 rows)

The row with path = {0} is the outer ring. The row with path = {1} is the inner ring (hole).