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

Nicolas Ribot nicolas.ribot at gmail.com
Wed Apr 11 01:01:12 PDT 2012


On 10 April 2012 12:04, Sandro Santilli <strk at keybit.net> wrote:
> On Mon, Apr 09, 2012 at 07:33:41PM +0200, Nicolas Ribot wrote:
>> Hmm much easier with Postgis Topology...
>>
>> (thanks Brent for the Topology example)
>>
>> By the way, is it the right way to use topology to simplify a layer ?
>
> It's one way, there may be multiple ones.
> Add this new way to to wiki ?

Done: http://trac.osgeo.org/postgis/wiki/UsersWikiSimplifyWithTopologyExt

>
> It'd be interesting to see some banchmarks of the two methods you reported.
>

Just som rough figures from my test:
Using first method, with a plpgsql function and spatial operators:
    • it takes ~ 7.5 second to process 96 multipolygons containing ~
47000 vertices.
    • it takes ~ 9 minutes to process the 36610 communes
(=municipalities), containing more than 512000 vertices

With Topology:
   • treating departements took 10.2 seconds on average.
   • I canceled the CreateTopoGeo after about 25 minutes.

> I'd point out that the toTopoGeom function does the association with you,
> directly giving you a TopoGeometry object back. Brent didn't use TopoGeometry
> at all, which is legit, but that's the intended mean to associate attributes
> to topologically-defined locations.
>
> I've been actually thinking that an ST_Simplify() override taking a
> TopoGeometry input might be a good idea. You would be simplifying the same
> up to twice each, but the usage would be simper.

I will play a bit with this object.

Thank you for the advices.

Nicolas

>
> --strk;
>
>>
>> create table new_dept as (
>>       select gid, code_dept, (st_dump(geom)).*
>>       from departement
>> );
>> create index new_dept_geom_gist on new_dept using gist(geom);
>>
>> -- create new empty topology structure
>> select CreateTopology('topo1',2154,0);
>>
>> -- add all departements polygons to topology in one operation as a collection
>> select ST_CreateTopoGeo('topo1',ST_Collect(geom))
>> from departement;
>>
>> -- create a new topo based on the simplification of existing one
>> -- should not be the right way to do it, but calling ST_ChangeEdgeGeom
>> failed with a simplify linestring
>> select CreateTopology('topo2',2154,0);
>>
>> select ST_CreateTopoGeo('topo2', geom)
>> from (
>>       select ST_Collect(st_simplifyPreserveTopology(geom, 10000)) as geom
>>       from topo1.edge_data
>> ) as foo;
>>
>> -- associates new simplified faces with points on surface, in the new_dept table
>> alter table new_dept add column simple_geom geometry(POLYGON, 2154);
>>
>> -- retrieves polygons by comparing surfaces (pip is not enough for
>> odd-shaped polygons)
>> with simple_face as (
>>       select st_getFaceGeometry('topo2', face_id) as geom
>>       from topo2.face
>>       where face_id > 0
>> ) update new_dept d set simple_geom = sf.geom
>> from simple_face sf
>> where st_intersects(d.geom, sf.geom)
>> and st_area(st_intersection(sf.geom, d.geom))/st_area(sf.geom) > 0.5;
>>
>> Nicolas
>>
>> On 9 April 2012 01:02, Nicolas Ribot <nicolas.ribot at gmail.com> wrote:
>> > For those interested, I've added an entry to the postgis wiki showing
>> > an example of polygon layer simplification:
>> >
>> > http://trac.osgeo.org/postgis/wiki/UsersWikiSimplifyPreserveTopology
>> >
>> > Nicolas
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
> --
>
>  ,------o-.
>  |   __/  |    Delivering high quality PostGIS 2.0 !
>  |  / 2.0 |    http://strk.keybit.net - http://vizzuality.com
>  `-o------'
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list