From: Regina Obe Date: Thu, 10 Jul 2008 13:16:20 +0000 (+0000) Subject: Examples of using ST_ExteriorRing and ST_NumInteriorRings X-Git-Tag: 1.4.0b1~859 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14d5b30f994a0b0424c2afa6e1d0cc55649fd433;p=postgis Examples of using ST_ExteriorRing and ST_NumInteriorRings git-svn-id: http://svn.osgeo.org/postgis/trunk@2837 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/reference.xml b/doc/reference.xml index 50230b92e..1703058c4 100644 --- a/doc/reference.xml +++ b/doc/reference.xml @@ -739,21 +739,46 @@ ST_Dimension - ST_ExteriorRing(geometry) + ST_ExteriorRing(polygon geometry) Return the exterior ring of the polygon geometry. Return - NULL if the geometry is not a polygon. + NULL if the geometry is not a polygon. Will not work with MULTIPOLYGON + +--If you have a table of polygons +SELECT gid, ST_ExteriorRing(the_geom) AS ering +FROM sometable; + +--If you have a table of MULTIPOLYGONs +--and want to return a MULTILINESTRING composed of the exterior rings of each polygon +SELECT gid, ST_Collect(ST_ExteriorRing(the_geom)) AS erings + FROM (SELECT gid, (ST_Dump(the_geom)).geom As the_geom + FROM sometable) As foo +GROUP BY gid; + - ST_NumInteriorRings(geometry) + ST_NumInteriorRings(polygon geometry) Return the number of interior rings of the first polygon in - the geometry. Return NULL if there is no polygon in the + the geometry. This will work with both POLYGON and MULTIPOLYGON types but only looks at the first polygon. + Return NULL if there is no polygon in the geometry. + +--If you have a regular polygon +SELECT gid, field1, field2, ST_NumInteriorRings(the_geom) AS numholes +FROM sometable; + +--If you have multipolygons +--And you want to know the total number of interior rings in the MULTIPOLYGON +SELECT gid, field1, field2, SUM(ST_NumInteriorRings(the_geom)) AS numholes +FROM (SELECT gid, field1, field2, (ST_Dump(the_geom)).geom As the_geom + FROM sometable) As foo +GROUP BY gid, field1,field2; +