[postgis-users] split donut polygons

Sandro Santilli strk at keybit.net
Wed Feb 15 08:28:37 PST 2012


On Wed, Feb 15, 2012 at 11:17:49AM -0500, Travis Kirstine wrote:
> Thanks Nicklas
> 
> I do agree that this is a bad idea.  I have checked the resultant
> geometries and they are invalid (using FME)
> 
> Original
> POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))
> 
> Results
> POLYGON((0 0,4 0,2 1,1 1,1 2,2 2,2 1,4 0,4 4,0 4,0 0))
> 
> Unfortunately, I cannot alter the application to render the donuts
> correctly.  I have consider extracting the interior rings as polygons
> and stacking them but as you had mentioned but this becomes very
> complicated (island within lakes within islands etc...)
> 
> Although the "bridge building"  method would result in invalid
> geometries it seems to work for this purpose (display only).
> 
> If anyone has any hints on how to build this query to create bad
> polygons : )  they would be appreciated

1) Dump the rings of your polygon
2) Find closest line between shell (path = 0?) to each of the holes
3) Add all rings boundaries + the lines found in (2) to a collection
4) Linemerge the collection of multilines
5) Verify the result is a single, closed line
6) Realize the resulting line is not simple (just for fun)
7) Pass the resulting line to ST_MakePoly

--strk; 

  ,------o-. 
  |   __/  |    Delivering high quality PostGIS 2.0 !
  |  / 2.0 |    http://strk.keybit.net
  `-o------'




More information about the postgis-users mailing list