| 1 | = An example showing how to simplify a multipolygon layer, keeping topology between objects = |
| 2 | |
| 3 | == What we want == |
| 4 | |
| 5 | Simplifying this layer [[Image(SPT_dept_ori.png)]] into this: [[image:SPT_dept_sim.png]] |
| 6 | |
| 7 | == The data == |
| 8 | |
| 9 | French administrative subdivisions, called "départements", will be used. Data can be downloaded here: [http://http://professionnels.ign.fr/DISPLAY/000/528/175/5281750/GEOFLADept_FR_Corse_AV_L93.zip] |
| 10 | |
| 11 | Data projection is Lambert-93, EPSG:2154 |
| 12 | |
| 13 | == Loading the data == |
| 14 | |
| 15 | {{{ |
| 16 | shp2pgsql -IiD -g geom -s 2154 DEPARTEMENT.SHP departement | psql |
| 17 | }}} |
| 18 | |
| 19 | == Principle of simplification == |
| 20 | |
| 21 | Based on the technique described here [[]], we extract linestrings out of polygons, then union and simplify them. |
| 22 | st_polygonize() is used to rebuild surfaces from linestrings. Attributes from the initial layer are associated with simplified polygons. |
| 23 | |
| 24 | == Steps == |
| 25 | |
| 26 | 1. First extract the input multipolygons into polygons, keeping their departement code. This will allow us to associate attributes to each part of multipolygons at the end of the process. |
| 27 | |
| 28 | {{{ |
| 29 | create table dep_poly as select gid, code, st_dump |
| 30 | }}} |