Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
579 views
in Technique[技术] by (71.8m points)

algorithm - How to intelligently degrade or smooth GIS data (simplifying polygons)?

I have detailed US county maps, from the TIGER LINE data sets. How might I sample, smooth, or degrade the data so that I get straighter, more boxy, less "noisy" shapes to represent the geographical features -- in this case just county boundaries and state lines, but maybe also in the general case?

The sampling could happen at rendering time if that can be done efficiently, or a parallel data set could be generated and stored. I am using PostGIS, and the lines are multi-polylines generated by shp2pgsql -- but any solution where you take a squiggly line and reduce it to a smoother line of roughly the same significance to a human interpreter would be very useful.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Douglas-Peucker is definitely the right approach. There are some simple ways to access implementations of it in PostGIS and QGIS that 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-Peucker is implemented as simplify, the syntax, detailed here at bostongis.org, is some variant of:

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

This worked very well even on the full national dataset, with some few errors that seem due to bad underlying data. It also turns out that in QGIS the menu item Tools > Geometry Tools > Simplify Geometries will export a simplified shapefile of any geometry and add it as a layer to your current project.

This is a pretty fundamental tool-set and I asked the question at too low a level, though it was nice to learn the underlying math, there is a good explanation of that here: http://www.mappinghacks.com/code/PolyLineReduction/, along with sample code that turns out not to be too necessary!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...