Saturday, May 11, 2013

Tracing buildings from OS OpenData Street View for Openstreetmap

First, it needs to be said. Automatic tracing and dumping data into Openstreetmap is not a good idea. This page is something I have been playing with as an aid to manual edits.

This is a simple summary of the steps I used. If you need more information, then you probably should not be doing this.

Source Data
Grab some data for the area of interest from Ordnance Survey.
The Gimp
Find the tile required and open in The Gimp. The following steps should isolate the buildings.
  • Select by colour, threshold set to 26, pick the centre of a building, avoiding the antialiased edges.
  • Sharpen selection.
  • Fill whole selection with black
  • Invert Selection
  • Fill whole selection with white.
  • Save image in bmp format.
Potrace
Make sure that you have the latest potrace that does geojson. With the required tif image from the OS data, run to following command:
potrace -b geojson -L XXXXXX -B YYYYYY -O 1 -a 0 tile.bmp
Replace XXXXXX and YYYYYY with the appropriate offsets for the tile being worked on. The required data is in the package downloaded from OS.
Quantum GIS
  • Create a new project with CRS OSGB 1936 / British National Grid. EPSG:27700.
  • Load a new vector layer, select the json file from potrace and make sure the CRS is as above. Make sure that the scale is making sense. It would be possible to load another layer of known good data as a check. Be sure to allow on the fly CRS transforms if the data you check against is not OSGB 1936.
  • Save the layer as a shapefile. Use the same CRS as the layer for the shapefile.
JOSM
The shapefile can now be loaded into JOSM. The polygons should line up well with the OS OpenData StreetView background images. However, there will still be a lot of manual cleaning up required. Extra nodes need to be deleted and squaring up done.

I am not sure if this actually makes much improvement over simply clicking over the background imagery by hand. Maybe someone else can improve this process a bit more. This is really written as a reminder to myself incase I come back to this later.

All this is done with free software. The initial idea came from the openstreetmap wiki. There is also a python program that can do this called Mapseg, but it is not very fast on my little computer.