I’ve just signed up for an OpenStreetMap account and thought I’d try out the offline map rendering, as I’ve just started a project to document the changing face of Alderney.

The wiki gives some good instructions for downloading the rendering XSLT scripts, but my first attempt to use them resulted in some very strange coastline clipping in the final SVG.

With a bit of hunting, I came across a Perl script in their collection that cleans the coastline data up nicely.

For the record, here’s the complete set of steps to going from nothing to a rendered map of Alderney. I’m using Fedora 11 with xsltproc already installed.

  1. Let’s grab the required tools from OpenStreetMap’s Subversion repository. These commands pull in a bit more than is strictly necessary, but the steps on their wiki seem to leave you without some of the symbols for the final map, unless I’ve misread something.

    $ mkdir osm
    $ cd osm
    $ svn co http://svn.openstreetmap.org/applications/rendering/osmarender/
    $ svn co http://svn.openstreetmap.org/applications/rendering/tilesAtHome/
    
  2. Now we’ll grab the raw map data for the area we want to render. I’ve found these coordinates by trial and error. They leave a small amount of water around the island, including Coque Lihou on the south, but excluding the Noires Putes.

    $ wget http://www.openstreetmap.org/api/0.6/map\?bbox\=-2.24,49.695,-2.15,49.735 \
    --output-document=alderney.osm
    
  3. Now we’ll correct the coastline data with a Perl script called close-areas.pl. However, the first time we use this, we’ll have to edit it to allow it to run on a newer version of the OpenStreetMap data than it’s expecting. Pull the script into your favourite editor and delete the line that does the check, which in my copy is line 114:

    die ("close-areas.pl does not support version $1") unless ($1 eq "0.5");
    
  4. Now correct the coast line, using the lat-longs of the area we downloaded:

    $ cd tilesAtHome
    $ perl close-areas.pl 49.695 -2.24 49.735 -2.15 < ../alderney.osm > ../alderney-closed.osm
    
  5. Time for rendering. We need to run the renderer in a particular directory too, and it expects the data to always be called data.osm. As I’m going to perform the rendering more than once, I’ll make a link to my file rather than renaming. The link won’t have to be remade each time, of course.

    $ cd ../osmarender/stylesheets
    $ ln -s ../../alderney-closed.osm data.osm
    $ xsltproc ../xslt/osmarender.xsl osm-map-features-z17.xml > alderney.svg
    

    On my box, with an Athlon 64 X2 4200, the render takes under five minutes.

Here’s the final result:

Alderney, by OpenStreetMap