Showing posts with label maps. Show all posts
Showing posts with label maps. Show all posts

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.

Monday, October 29, 2012

Openstreetmap Zoom

I have played around with this before. Having recently set up Mapnik again to render Openstreetmap data. Currently it is using the standard Openstreetmap osm.xml file so should look like the mad used on the main website.

This animation is created by rendering each frame with Mapnik. The script is based on a hack of the standard generate_image.py script that comes with Mapnik. It simply loops, and for each loop a new bounds is calculated to provide the zoom effect.

A seperate script is used that adds the watermarks in the bottom corners of each frame. This was done with the help of ImageMagick. Finally, avconv was used to convert the frames into an mp4 file.

The next step is to make an animation based on a GPX file. That will take a GPX file as input and provide a zooming animation that shows the start, and an overview of the whole GPX track.

Wednesday, October 10, 2012

Garmin Vista HCx

Some time ago, I purchased a Garmin etrex Vista HCx. Certainly not the most sophisticated GPS system available, but still good fun. It works well in the car, the pocket and on the bike. The only real downside was that the maps that come with it are fairly limited, and it would work out expensive to purchase all the maps I may want to use with it.

That said, it still works very well for recording tracks. When I first had the device, Openstreetmap was still fairly incomplete in my area, so it was good fun uploading GPX traces to help add detail to the map.

Eventually, I found out how to create a map from the Openstreetmap data that can be loaded into the Garmin etrex Vista HCX device. It requires a number of steps, but these are easy in Linux.

Grab the data

The data that is used to build the Openstreetmap map is freely available. There are a number sources for the data, but it would not be normal to want the entire world database. The people at Geofabrik provide a usefull service where they maintain a selection of extracts. Please remember this is provided as a service, so be kind to their servers. The extract I get is the one for Great Britain.

wget http://download.geofabrik.de/openstreetmap/europe/great_britain.osm.pbf

Get the tools

A number of tools are required to process the data to make it useful for the Garmin. Following is a list of tools that I have found work for me.

Splitter
Used to split the map into manageable pieces.
Mkgmap
Converts the OSM data into format suitable for Garmin device

Use the tools

These tools can be used as follows. This is not a definitive guide. Best refer to the relevant sites for the tools, but this is how I am using the commands.

splitter

java -Xmx1536m -jar splitter.jar \
   --max-nodes=1000000 \
   --mapid=63240001 \
   great_britain.osm.pbf

This will generate a series of files from the input.

mkgmap

CMD="java -Xmx1024m -jar mkgmap.jar \
   --route --remove-short-arcs \
   --add-pois-to-areas --index \
   --location-autofill=bounds \
   --generate-sea"
for f in 6324*.osm.pbf
do
    echo $f
    $CMD $f
done

After this is run, we should have a number of .img files. At this point, it may be possible to use these tiles with the Garmin map tool for the PC. But why bother. Let us just bundle these all up into one large file.

java -Xmx1024m -jar mkgmap.jar \
   --gmapsupp --family-id=50 --product-id=1 63*.img

This should result in a single map file named gmapsupp.img. All we need to do now is copy this to the Garmin directory on the SD card used by the Etrex Vista HCx.

Results