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

Sandro Santilli strk at keybit.net
Wed Apr 11 05:21:15 PDT 2012


On Wed, Apr 11, 2012 at 01:40:01PM +0200, Nicolas Ribot wrote:

> Method 1: using one SQL query:
> 
> select (st_dump(st_polygonize(distinct geom))).geom as geom
> from (
>     select (st_dump(st_simplifyPreserveTopology(st_linemerge(st_union(geom)),
> 10000))).geom as geom
>     from (
>         select st_exteriorRing((st_dumpRings(geom)).geom) as geom
>         from expl_dep
>         ) as foo
> ) as bar;
> 
> -- takes 6.1 to 6.4 seconds

...

> Method 2, using topology wrapped in a function:
> (topo1 and topo2 are created outside the function):
> 
> create or replace function testSimplTopo() returns text as $$
> 
>     select ST_CreateTopoGeo('topo1',ST_Collect(geom))
>     from expl_dep;
> 
>     select ST_CreateTopoGeo('topo2', geom)
>     from (
>            select ST_Collect(st_simplifyPreserveTopology(geom, 10000)) as geom
>            from topo1.edge_data
>     ) as foo;
> 
> $$ language sql;
> 
> -- takes 12.0 to 12.3 seconds.

Why are you populating 'topo1' topology at all ?
You're doing the hard work twice, which matches the double
time it takes compared with the direct call.

--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