[OSM-dev] Polygon relationificator

Frederik Ramm frederik at remote.org
Mon Sep 14 12:54:52 BST 2009


Hi,

Iván Sánchez Ortega wrote:
> You can see where this goes. If the input polygons are non-overlapping and 
> adjacent, I could redraw the edges of the polygons as graph edges, put a 
> graph node whenever three (or more) polygons touch each other, and then apply 
> some graph theory to convert every polygon to a set of graph edges ( = 
> relation of ways = multipolygon with several outer ways )

I have done this a number of times semi-manually:

1. load shapefile in PostGIS
2. have PostGIS compute intersection of every polygon with every other 
polygon; this (one line of SQL) will result in one linestring for each 
border between two polygons - make the linestring table so that it has 
two attributes, one for "first polygon" the other for "second polygon"
3. dump resulting linestrings to shapefile
4. read them using a Perl script (available on request but has lots of 
special cases, so needs adaptation to the task at hand), generate OSM 
ways from the linestrings and reconstitute them into relations by 
looking at the linestring attributes.

Bye
Frederik







More information about the dev mailing list