The ST_Simplify PostGIS function is able to simplify and generalize either a (simple or multi) linear or polygonal geometry using the Douglas-Peucker algorithm (for more details, go to http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm). Since it can create invalid geometries in some cases, it is recommended that you use its evolved version—the ST_SimplifyPreserveTopology function—which will produce only valid geometries.
While the functions are working well with (multi) linear geometries, in the case of (multi) polygons, they will most likely create topological anomalies such as overlaps and holes at shared polygon borders.
To get a valid, topologically simplified dataset, there are the following two choices at the time of writing:
- Performing the simplified process on an external GIS tool such as GRASS
- Using the new PostGIS topological support
While you will see the new PostGIS topological features in the Simplifying geometries with PostGIS topology recipe, in this one you have been using GRASS to perform the simplification process.
We opened GRASS, created a GIS data directory and a project location, and then imported in the GRASS location, the polygonal PostGIS table using the v.ogr.in command, based on GDAL/OGR as the name suggests.
Until this point, you have been using the GRASS v.generalize command to perform the simplification of the dataset using a tolerance (threshold) expressed in meters.
After simplifying the dataset, you imported it back to PostGIS using the v.ogr.out GRASS command and then opened the derived spatial table in a desktop GIS to see whether or not the process was performed in a topologically correct way.