I encountered a problem simplifying set of polygons that are adjacent. If I simplify each polygon separately with the Douglas–Peucker algorithm (which is used by many open source tools), the resulting polygons are usually not adjacent anymore. This problem exists, for example, when simplifying borders of countries/provinces.

Does anyone has a good solution for it, preferably to be done in postgis?

-
Can any one explain me in more details as to how can I resolve above issue using C++ concepts? Is it really possible to simplify adjacent polygons of shapefile? Can I use Douglous Peucker Algorithm in this case if yes then how? – user21354 Aug 23 '13 at 11:22

A topological vector model will provide what you need. In a non-topological storage (such as a shapefile), a single edge between geometries is stored twice. In a topological vector, the areas are stored separately from the lines, so adjustments can be made without effecting topology. I couldn't find a good diagram, so I created this simple example, where the areas A, B and C are computed from the intersections of the lines (connecting 1-4) which separate them.

This model is used by ArcInfo as coverages, in GRASS as its default vector model, and can be used in PostGIS with the experimental PostGIS Topology tool. Perhaps a simpler solution is converting your data into linework, removing the redundant segements, and then recreating your polygons after simplification.

-

You want to turn your polygons into lines, make those lines be simple coverage edges, simplify those edges, then build them back up into polygons again, and finally use point-in-polygon to re-join the attributes of the old polygons with the new ones.

``````CREATE TABLE rings AS SELECT (ST_DumpRings(polys)).geom AS rings FROM polytable;
CREATE TABLE simplerings AS SELECT ST_Union(rings) AS simplerings FROM rings;
CREATE TABLE newpolycollection AS SELECT ST_Polygonize(ST_Simplify(simplerings, 10.0)) AS geom FROM simplerings;
CREATE TABLE newpolysnoattributes AS SELECT (ST_Dump(geom)).geom FROM newpolycollection;
CREATE TABLE newpolytable AS SELECT new.geom, old.attr FROM newpolysnoattributes new, polytable old WHERE ST_Contains(new.geom, ST_PointOnSurface(old.polys));
``````

There are errors in the above, but the core concept is there. You can do it all in one query if you like.

-
Interesting solution, I will give it a try in couple of days. – stachu Aug 4 '10 at 7:55
Excellent solutions, +1 for providing a code approach. – fmark Aug 4 '10 at 8:57
I know this is fairly old, but theres some problems with Pauls solution, see the lower part of my write up here: webspaces.net.nz/page.php?view=polygon-dissolve-and-generalise – user6512 Mar 23 '12 at 3:10

To avoid this problem, you should model your data using topological constraints. http://mapshaper.org/ does it.

-

You need to tessellate. In the old ARC/INFO theory of creating geometry, two adjacent geometries is created by one polyline and shared this polyline. Therefore when you generalized, it generalized both borders because it referenced the same polyline.

-