[postgis-users] Simplifying a multipolygon layer, keeping polygon connection

Sandro Santilli strk at keybit.net
Wed Apr 11 05:59:41 PDT 2012

On Wed, Apr 11, 2012 at 02:30:31PM +0200, Nicolas Ribot wrote:
> > Ok, I see you're using 'topo1' as input for the simplification.
> > Instead you may want to simplify the input directly:
> >
> > select ST_CreateTopoGeo('topo1', ST_Collect(
> >          ST_SimplifyPreserveTopology(geom, 10000)
> >       ))
> > from expl_dep;
> >
> Yes, this was the reason: hoping the noded edges could be simplified
> without loosing the connectivity (which is the case :) )
> In one pass, I fall back to the classical "simplify with broken
> topology" as shown on the picture.

But that's due to the way you associate faces with original polygons.
If each and every face is associated to exactly _one_ polygon you'd 
be fine. You could get PointOnSurface of each face and check each of
the original polygons for containment (ST_Contains).

Alternatively you could still construct the topology with full-precision
edges and then simplify the edges in-place (possibly after a CopyTopology),
using ST_ChangeEdgeGeom. That way the _original_ nodes will remain the same
and you'd be only simplifying the edges connecting them. Beware in this
case that simplification might still introduce topology errors but such
errors would be cought by ST_ChangeEdgeGeom with throwing an exception.

You may catch the exception to reduce tolerance for a given edge or bypass
all checks by editing the edge_data table directly and cross your fingers :)
ValidateTopology should then tell you what you broke, if you want to fix
manually after the fact.


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

More information about the postgis-users mailing list