Tuesday, 16 October 2012

Local maps

Things have been pretty busy over the last few months. Partly because we are still working through the house decorating, and fixing. Partly because we got a puppy (which provides endless amusement). And partly because we are getting more involved in various local activities. One of those is helping to produce  a newsletter for one of our local societies. I thought some of the items in the newsletter might benefit from a map, so I set off on a journey to work out how best to produce street plans of a small town, with various content overlaid. As I should have known, that's turned out to be something of a diversion.

A few years ago, my first effort at generating maps from OSM data was based on overlaying the standard renders with KML files. That worked fine when I wanted to highlight a route, or a few locations, over a slippy map and place it on a web site.

Later I got it into my head that I would try to replicate the old Bartholomew's half-inch maps using OSM data. I wanted to generate maps that covered quite a large area (roughly the size of a county), and I wanted to do quite a lot of manipulation of the data. I used Mapnik to do the rendering, and a Postgis database to manage the content, with various home-made tools based on SQL and Perl.

Now I only need to cover quite a small area. Most of the time I just want to map the centre of a small town, so the maps are only a mile or so across. Sometimes I will want to cover a bit more of the surrounding area, but still no more than a few miles in each direction. The amount of data that I need to crunch is quite small.

At the moment I'm using Quantum GIS (QGIS), working directly from OSM extracts. There are a few glitches, but for most purposes it works fine. I'm not going to attempt a whole cook-book, but here are some tips, based on my experience so far:

  • I am using the Openlayers plugin in QGIS. Openlayers will add a raster layer to your map pulled from the standard Mapnik render, or from Bing imagery (or various other sources). These help with positioning your overall map, selecting data to download, and editing stuff that you want to add.
  • I use the OSM plugin in QGIS. Among other things, over a small area, that will download data directly from the OSM database, which gets you started quickly. 
  • Change the default OSM styles. I got hold of the "light" styles described here, then edited them to suit my purposes. They look a lot better than the standard styles, particularly when you are overlaying data to highlight features on top of a base map
  • For areas that are too big to work directly from OSM data, I'm downloading the Planet data, and extracting a subset using OSMOSIS. This isn't very sophisticated in the way it trims the bounding box, so you need to add a fairly generous margin to pick up any long ways that run outside the area you are interested in.
  • Where I want to edit data for my own purposes, I'm using Perl to do automated edits on my local data extract, or JOSM on my local extract for manual edits. Every time I do this I'm scared I will accidentally upload my edits back to OSM. If there is a less risky alternative I'd love to hear about it. So far I haven't hit the wrong button. On the sort of data volumes I'm handling this is fast enough, and much easier than Postgis, but I'm beginning to miss some of the more sophisticated Postgis tools.
  • I don't think I've yet worked out the best way to add extra GIS data for my own use. The basics - to add a layer, draw some features, edit them, apply styles and labels - are straightforward enough. However I'm starting to want to go on and edit more attributes, add a mix of lines and points, and the like. But without going into full-blown database management. The tools all seem to be there, but I've not got my head around how to do it easily (yet).
  • I haven't found a decent way of showing the shape of the landscape on my small maps, because the free elevation data is too coarse. Across a slightly wider area covering a few miles, it's not hard to import OS Landform data (ASC format) into QGIS, re-scale it to get smoother shading, then colour according to elevation, add hillshading, contours, or whatever.
  • I've been reprojecting stuff to the National Grid Coordinate system (OSGB 27700, rather than WGS 84). To my eyes, the proportions looks more as they should, and it also allows me to work in map units of a metre, rather than degrees, or pixels.
  • Don't expect everything to work. I'm still having problems with roundabouts, and multipolygons with inners and outers. Most of the time this doesn't matter to me, and where it does I'm kludging the data to work around it. Maybe there's a better solution, but I can live without one for now.
  • In my experience, using data in different ways is one of the best ways of improving quality. So I make a note of anything in the base data that is going to need fixing, so that I can go back and fix it later. But I make sure that I handle the fixes separately from anything in the data that I want to adjust for my own purposes. That way there is no confusion between "I want my map to look like this" and "OSM should hold the data like this". I'm now starting to use separate data and separate layers for the stuff that I pull directly from OSM, and leave unchanged, and the stuff that I am pulling from OSM, and editing before I use it. That's partly just because it makes it easier to manage, but I think it's probably good practice anyway.
The bottom line is, if you want to generate a map of a relatively small area, QGIS may well do the job for you. It isn't a solution straight out of the box, but the learning curve isn't as steep as some of the alternatives. that I've tried.

And if you enjoy doing this stuff, then you might find that the person who edits the newsletter or the web site for one of your local societies might welcome some help.