[OSM-dev] ogr2poly.py with buffering and simplifying

Frederik Ramm frederik at remote.org
Mon Dec 5 19:48:35 GMT 2011


On 12/05/2011 07:29 PM, Josh Doe wrote:
> I created a Python script to convert OGR supported files (Shapefile
> and many others) to the polygon filter file format used by Osmosis and
> other tools. It will optionally buffer and simplify polygons for you.
> You can buffer point and line features to create polys as well.

I have something similar done in C but always found it too fragile to share:


It takes a "relation/xxx/full" OSM as input, and writes out an OSM file 
again (which you can view/modify in JOSM then convert to poly).

The clou with this one is that it will buffer and simplify but it will 
guarantee that the original polygon is always fully contained in the 
result - i.e. it will never cut off an edge through over-eager 
simplification. This is done not by clever algorithms but by simply 
grinding through a number of buffer and simplification parameters until 
the desired result is found.

I have found this to work well for polygon generation, except the glitch 
explained here 
http://www.osgeo.org/pipermail/geos-devel/2011-May/005208.html. If you 
can solve *that* problem then I'll even consider installing Python.


Frederik Ramm  ##  eMail frederik at remote.org  ##  N49°00'09" E008°23'33"

More information about the dev mailing list