[postgis-users] Donut-Polygon

Kevin Neufeld kneufeld at refractions.net
Thu Feb 5 10:29:15 PST 2009


Use ST_DumpRings to extract the rings, then exclude the ones you don't want and then rebuild your polygon.
http://postgis.refractions.net/documentation/manual-svn/ST_DumpRings.html

ie.
-- A polygon with 6 inner rings, we exclude all but rings 3 and 5
SELECT ST_AsText(ST_BuildArea(ST_Collect(geom))) AS the_geom
FROM (SELECT (ST_DumpRings(
     'POLYGON (( 0 0, 0 7, 10 7, 10 0, 0 0 ),
               ( 1 4, 3 4, 3 6, 1 6, 1 4 ),
               ( 4 4, 6 4, 6 6, 4 6, 4 4 ),
               ( 7 4, 9 4, 9 6, 7 6, 7 4 ),
               ( 1 1, 3 1, 3 3, 1 3, 1 1 ),
               ( 4 1, 6 1, 6 3, 4 3, 4 1 ),
               ( 7 1, 9 1, 9 3, 7 3, 7 1 )
               )'::geometry)).*) AS foo
WHERE NOT ( ARRAY[1,2,4,6] @> path );

                                    the_geom
------------------------------------------------------------------------------
  POLYGON((0 0,0 7,10 7,10 0,0 0),(7 4,9 4,9 6,7 6,7 4),(4 1,6 1,6 3,4 3,4 1))
(1 row)

Cheers,
Kevin

Albert Krueger wrote:
> Hi at all,
> 
> I have a Donut-Polygon with a number of Innerrings. Now I would like to 
> delete some Innerrings. For Example I have a polygon with five 
> Innerrings. ButI want to delete the second and the fourth Innerring. Has 
> anyone an idea how I can get a polygon with only three Innerrings 
> (1,3,5) then?
> 
> Thank you!
> 
> Best regards
> 
> Albert
> 
> 
> _________________________________
> LOVE at LYCOS ist jetzt ganz neu - melde dich kostenlos an, lerne neue 
> Leute kennen und finde deinen Flirt!
> Jetzt flirten! 
> <http://bc.lycos-europe.net/lnl/bc.php?loveatlycos_promo_mailsig|http://love.lycos.de/start.action?utm_campaign=mp&utm_source=mailsig> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list