[postgis-users] Method to remove overlaps in a layer

Sandro Santilli strk at keybit.net
Thu Mar 15 10:01:50 PDT 2012


On Thu, Mar 15, 2012 at 05:59:00PM +0100, Sandro Santilli wrote:
> On Thu, Mar 15, 2012 at 12:56:38PM -0400, Pierre Racine wrote:
> > >  1. find out intersecting pairs into cache (id1,id2,geom1,geom2)  2. update cache
> > > set geom1 = st_difference(geom1, geom2)  3. update main set geom = c.geom1
> > > from cache where id1 = id
> > 
> > Hum... Life is never that easy.
> > 
> > That would work if one polygon would always overlap with only one polygon but if one polygon is overlapped by two polygons or more the same polygon as two differences associated with it in the second step and only the last one will remains in the last update...
> 
> True, should be an iterative process until "cache" becomes empty.

I would add that every iteration (ST_Difference call) would introduce
small changes in your boundaries possibly introducing gaps or new
overlaps.

You should really be constructing a topology out of that dataset,
you know ? Will be probably slow but I'm sure you can survive :)

--strk;

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




More information about the postgis-users mailing list