The Need for Speed
I do all my personal GIS
work on a 2010 MacBook Pro, which, although loaded with 8Gb of RAM,
working with a detailed street dataset can really slow things down. In order to speed things up I hit upon the idea of creating myself a set of pre-rendered raster map tiles that could be loaded in lieu of displaying a large vector file of streets (another option would have been an SSD,
but that costs a little more, probably with less benefit).
Creating My Tiles
For my maps, I planned to use OSM-bright
as it is nice and clear, and familiar to most people – it looks like people think a map should look.
I used Mapzen to download the most up to date osm.pbf file for Sydney. Previously I’ve used the data from geofabrik, but wanted an easy to use rectangular area and didn’t feel like working out how to clip it down to a workable area with osm2pgsql (if that is even possible11).
I already had an install of PostGIS available as part of the Boundless Open Geo Suite so was able to pick up the OSM OSM-Bright tutorial at the ‘osm2pgsql’ stage, although I used pgAdmin3 to create the database rather than Terminal.
There was little bit of confusion of the actual folder structure for the simplified-land-polygons-complete-3857 and land-polygons-split-3857 files; the guide tells you to put them in a directory named ‘shp’ which doesn’t exist in the download. After a bit of research, I found the following worked.
At one part of the tutorial, it requires you to run TillMill (if you haven’t previously) so that it can set up a few folders which OSM
-Bright needs. Unfortunately Tillmill was broken with the Mac OS X 10.10 update, so when I tried launching it I was greeted with an eternally spinning wheel.
Fortunately, as the code is publicly available, I managed to find a solution and quick guide to installing it from the source code. It doesn’t create an App, but does allow it to run.
git clone https://github.com/mapbox/tilemill.git
I ran into a couple of problems with this; first off was not having NPM installed which was easily fixed with a package from Node.js. However I then found that the current version (v0.12.2) caused install errors and had to downgrade to v0.10.36 to get it working.
Once everything was built I just needed to do
./index.js and then go to http://localhost:20009 after the server was running.
Since I had finished the OSM-Bright tutorial, I had a ‘Sydney OSM-Bright’ project which opened (a little slowly as it has to download some extra bits), and was able to pan and zoom my way down to Sydney.
From here, it was a simple case of selected the export to MBTiles option, changing a few parameters and waiting about 40 minutes while TillMill did it’s thing. Conveniently it does give you an idea of filesize based on your selections, so you can avoid accidentally tasking the creation of millions tiles and a multi-day export process.
Displaying the Results
At this point, I was expecting to have to set up a tileserver, and had already installed Tilestache to facilitate it. At that point, I found a comment that later versions of QGIS supported MBTiles directly, so fired it up and tried adding them as a raster layer.
For the first run I exported the MBTiles from TillMill for zoom levels 10-16, which is good for scales up to about 1:6,200 (since the tiles are images they get a little blurred at larger scales. I might try exporting down to zoom level 17, but that will result in a file 4x larger (as each zoom level creates four tiles for each tile above it). Render speed is fantastic though: far, far better than using vector layers for the basemap.
You can see one further advantage of using OSM data here – the spiral shape of the Albert “Tibby” Cotter bridge over Anzac Parade is visible, and it was only finished a month or two ago.