How to intelligently decompose or smooth GIS data (simplifying polygons)?

I have detailed maps of the county of USA from the TIGER LINE dataset. How can I try, smooth, or degrade the data so that I get clearer, more square, less β€œnoisy" forms for representing geographic features - in this case, only county borders and state lines, but perhaps in the general case too?

Sampling can occur during rendering, if it can be done efficiently, or you can create and save a parallel dataset. I use PostGIS , and the lines are multi- shp2pgsql generated by shp2pgsql , but any solution where you take a squiggly line and reduce it to a smoother line, about the same significance for a human translator, would be very useful.

+49
algorithm geometry gis postgis
Dec 04 '09 at 21:59
source share
7 answers

The problem with just dropping the dots is that you can quickly distort the shape of the original polygon. It is better to approach him from a different direction; start with a basic approximation of the polygon, and then complement it to your complex shape.

A great example of this approach is the Douglas-Pukeker algorithm . You start with two vertices taken from a full polygon. Add a third vertex, choosing one that lies farther from the edge drawn between the first two vertices. Continue adding points until you get something that closely resembles your original polygon.

+30
Dec 04 '09 at 22:13
source share
β€” -

Douglas-Pecker is definitely the right approach. There are several easy ways to access its implementation in PostGIS and QGIS, which I thought I would add here for those who come across this post with a similar question. The goal is to start with something like this:

alt text

and end up with something like this:

alt text

In PostGIS, Douglas-Pecker is implemented as simplify , the syntax described in detail here at bostongis.org is some option:

SELECT transform(simplify(transform(the_geom, 2249), 500),4326) from the_geo_table

This worked very well even for a complete national dataset, with some errors that seem due to invalid base data. It also turns out that in QGIS, the menu item Tools > Geometry Tools > Simplify Geometries exports a simplified shapefile of any geometry and adds it as a layer to the current project.

This is a fairly fundamental set of tools, and I asked the question too low, although it was nice to learn basic math, there is a good explanation here : http://www.mappinghacks.com/code/PolyLineReduction/ along with sample code that is not too necessary!

+61
Dec 05 '09 at 9:25
source share

Instead of QGIS, I suggest using ogr2ogr because it does not delete polygons !

 ogr2ogr output.shp input.shp -simplify 0.0001 
+19
May 08 '13 at 17:14
source share

Here's a simple iterative smoothing algorithm:

for each three consecutive points on any path, if the midpoint has no intersections and is within a small threshold angle of the direct path between two external points, delete it.

Repeat until completed.

+8
Dec 04 '09 at 22:04
source share

You can also try the Visvalingams algorithm, which iteratively removes the least tangible part of the string. Here is a detailed explanation of this algorithm:

+7
Mar 27 '13 at 23:36
source share

You can also use Simplify.js , which uses a combination of Douglas-Peucker and Radial Distance. There are also links to many ports in other languages ​​listed in the github project

+4
Oct 17 '13 at 17:03
source share

@Unmounts answer is correct, but I would like to add one more sentence.

Always use the ST_SimplifyPreserveTopology function instead of the ST_Simplify in PostGIS. Both use the same basic algorithm (Douglas-Paker), but the first avoids any simplifications that could lead to incorrect geometry. For example, ST_Simplify can lead to geometry that intersects itself.

0
Dec 07 '18 at 22:05
source share



All Articles