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

Nicolas Ribot nicolas.ribot at gmail.com
Mon Apr 9 10:33:41 PDT 2012


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 ?

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



More information about the postgis-users mailing list