Simplifying geometries with PostGIS topology
In a previous recipe, we used the ST_SimplifyPreserveTopology
function to try to generate a simplification of a polygonal PostGIS layer.
Unfortunately, while that function works well for linear layers, it produces topological anomalies (overlapping and holes) in shared polygon borders. You used an external toolset (GRASS
) to generate a valid topological simplification.
In this recipe, you will use the PostGIS topology support to perform the same task within the spatial database without needing to export the dataset to a different toolset.
Getting ready
To get started, follow the ensuing steps:
Be sure that you have the PostGIS topology support enabled in your database instance. This support is packaged as a separate extension and, if you are using PostgreSQL 9.1 or newer versions, you can install it using the following SQL
CREATE EXTENSION
command:postgis_cookbook=# CREATE EXTENSION postgis_topology;
Download the administrative area archive for Hungary...