Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a few multipolygons that have several hundred points in them. I'm looking to create less complex "thumbnails" polygons.

Naturally I'm attempting to use the simplify method, which is supposed to apply the Ramer-Douglas-Peucker algorithm. However, it doesn't seem to be working:

>>> m = Multipolygon.objects.get(id=1)
>>> m.geometry.num_points
1007
>>> m.geometry.simplify(0).num_points
1007
>>> m.geometry.simplify(1).num_points
0
>>> m.geometry.simplify(0.5).num_points
0
>>> m.geometry.simplify(10).num_points
0

I'm clearly missing something. When I simplify, I either get the original polygon back or an empty one, depending on the tolerance value that I use. How is the tolerance parameter supposed to work?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

The tolerance value is specified in map units: if two points are within the snapping tolerance, they are collapsed. So if you have geographic coordinates, simplify(1) would collapse everything to the nearest degree. Try something like simplify(0.0001) to start, or smaller depending on the resolution of your input data.

You may also be interested in this snippet, which allows you to specify precision as a number of points to retain in the output geometry.

share|improve this answer
    
Thanks! All of my values are in lat/lng (wgs84), and nearby points are probably within 100m, so a tolerance of 1 degree is way too much! The snippet is great too, that was going to be my followup question. –  Seth Aug 17 '10 at 4:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.