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

Sandro Santilli strk at keybit.net
Thu Apr 12 08:44:51 PDT 2012

On Thu, Apr 12, 2012 at 11:21:01AM -0400, Pierre Racine wrote:
> So I reprocessed the two polygons below in a topology have tolerance=0. However I still get the two same geometries in ovlp.test03_topo. I was expecting three polygons: 1 non-overlapping part for each and 1 representing the overlapping shared part with I don't know which attribute. 

You're looking at the _complexes_ (TopoGeometry), not at the _primitives_.

At the primitive levels, faces do _not_ overlap.
Only some faces are used by more than one TopoGeometry.

Now you'll see that we don't have very friendly TopoGeometry editing functions
so you're left on your own in cleaning up overlaps/underlaps. It'll be a matter
of removing faces from the definition of one or another TopoGeometry
(delete from topo3.relation where...)

The query would tell you which faces are used by multiple TopoGeometry objects,
so you know where overlaps are:

 SELECT r.element_id as face, array_agg(r.topogeo_id) as geoms
 FROM topo3.relation r
 WHERE r.element_type = 3 -- 3 == face
 GROUP BY face
 HAVING count(r.topogeo_id) > 1;

The numbers in the 'geoms' array are TopoGeometry identifiers,
you can query your layer by topogeom identifier using id(topogeom).


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

More information about the postgis-users mailing list