ST_ExteriorRing — Renvoie une ligne représentant l'anneau extérieur d'un polygone.
geometry ST_ExteriorRing(geometry a_polygon);
Renvoie une LINESTRING représentant l'anneau extérieur (coquille) d'un POLYGONE. Renvoie NULL si la géométrie n'est pas un polygone.
|
|
|
Cette fonction ne prend pas en charge les MULTIPOLYGONES. Pour les MULTIPOLYGONs, utilisez conjointement avec ST_GeometryN ou ST_Dump |
Cette méthode implémente la spécification OGC Simple Features Implementation Specification for SQL 1.1. 2.1.5.1
Cette méthode implémente la spécification SQL/MM. SQL-MM 3 : 8.2.3, 8.3.3
Cette fonction prend en charge la 3D et ne supprime pas l'indice z.
Extract the exterior ring from a Polygon with a hole.
WITH input(geom) AS (VALUES (
'POLYGON((0 0,2 9,9 11,14 6,12 0,0 0),(4 3,9 3,10 7,5 8,4 3))'::geometry
))
SELECT geom AS input_polygon,
ST_ExteriorRing(geom) AS exterior_ring
FROM input;
POLYGON((0 0,2 9,9 11,14 6,12 0,0 0),(4 3,9 3,10 7,5 8,4 3)) | LINESTRING(0 0,2 9,9 11,14 6,12 0,0 0)
For a MultiPolygon, dump the component Polygons before extracting their exterior rings. Both component Polygons in this example have holes.
WITH input(geom) AS (VALUES (
'MULTIPOLYGON(
((0 0,2 9,9 11,14 6,12 0,0 0),(4 3,9 3,10 7,5 8,4 3)),
((18 1,18 10,29 10,31 4,25 0,18 1),(21 3,25 2,28 5,25 8,21 7,21 3))
)'::geometry
))
SELECT part.geom AS input_polygon,
ST_ExteriorRing(part.geom) AS exterior_ring
FROM input
CROSS JOIN LATERAL ST_Dump(geom) AS part
ORDER BY part.path;
POLYGON((0 0,2 9,9 11,14 6,12 0,0 0),(4 3,9 3,10 7,5 8,4 3)) | LINESTRING(0 0,2 9,9 11,14 6,12 0,0 0) POLYGON((18 1,18 10,29 10,31 4,25 0,18 1),(21 3,25 2,28 5,25 8,21 7,21 3)) | LINESTRING(18 1,18 10,29 10,31 4,25 0,18 1)
Extract exterior rings from a table of Polygons.
SELECT gid, ST_ExteriorRing(geom) AS ering FROM sometable;
For a table of MultiPolygons, dump the component Polygons and collect their exterior rings into a MultiLineString.
SELECT gid, ST_Collect(ST_ExteriorRing(geom)) AS erings FROM ( SELECT gid, (ST_Dump(geom)).geom AS geom FROM sometable ) AS foo GROUP BY gid;
This example returns the 3D exterior ring of a Polygon.
SELECT ST_ExteriorRing(
'POLYGON Z ((0 0 5,4 0 5,4 3 5,0 3 5,0 0 5))'
);
LINESTRING(0 0 5,4 0 5,4 3 5,0 3 5,0 0 5)