52 :: State of the Map : Building businesses using OpenStreetMap

Building businesses using OpenStreetMap
Eric Rodenbeck, Stamen

Watched this video this morning. Since I follow Stamen somewhat online, I can’t say much was new to me in the this presentation either. But it was a good excuse to check out maps.stamen.com to see what lovely tiles they offer.

Unfortunately, the terrain tiles are US only but the watercolour and toner tiles are free for all. And not only that, the recipe of how they make these sets available are available on github.

I’m just to going to copy the requirements and dependencies of what’s necessary to serve up such tiles to the work, because I’m increasingly interested in this capability:



The short version is: There are a lot.

The long version is: The gritty details of installing some of the tools that Toner uses are outside the scope of this document. We’ve tried to give you the shape of what you need to do and linked to the available documentation elsewhere.

Software Dependencies (required)

Software Dependencies (optional)

Data Dependencies (required)

Database Tables

The Toner stylesheets need access to a pair of PostGIS databases:

  • A database containing PlanetOSM data (as created by the osm2pgsql script) and coastline using the spherical mercator projection (EPSG:900913). See below for details.
  • A database containing NaturalEarth data, as created by the shp2pgsql script (this is installed with PostGIS), using the spherical mercator projection (EPSG:900913). See below for details.

OpenStreetMap (OSM)

OSM publishes freely available downloads of their entire dataset at http://planet.openstreetmap.org. Instructions for installing and setting up OSM are outside the scope of this document but the OSM site has thorough documentation available at: http://wiki.openstreetmap.org/wiki/PostGIS

If you don’t want to install the entire OSM planet database but want to render tiles for a smaller area you can also use the MirrorOSM tile provider in TileStache to retrieve and store OSM data in PostGIS. Details are available over here:


You will also need to add a copy of the OSM coastline to your planet_osm database. The OSM coastline is distributed as a shapefile that you will need to import using the ‘shp2pgsql’ program:



Toner uses a table containing OSM-derived data called ‘planet_osm_motorways’. There’s a handy PGSQL script called ‘motorways.pgsql’ in the ‘osm’ table that you can run (once you’ve set up your planet_osm tables) to create the new table.

Natural Earth

NaturalEarth is a public domain map dataset of various cultural and vector datasets. It is available for download at: http://www.naturalearthdata.com/

Toner uses many, but not all of the datasets in NaturalEarth so the easiest thing is just to grab the shapefiles we use as a single compressed file over here:


This file contains the 13 NaturalEarth datasets Toner uses as shapefiles projected using EPGS:900913 (sometimes known as “spherical mercator” which really just means “good for making map tiles”). They also correct a known issue with the NaturalEarth shapefiles where polygons crossing the 180° meridian start to behave badly.

You will still need to use the ‘shp2pgsql’ program to import them in to your PostGIS database.

If you want to install of all NaturalEarth from scratch there are a few things you should be aware of first.

The various datasets are available as separate downloads but here’s a simple shell script that will download them all, one at a time:


NaturalEarth is distributed using the WGS84 map projection so you will need to reproject all the various shapefiles (in to the spherical mercator projection) before importing them in to your database.

Here’s another simple shell script that wraps up the entire process of converting the NaturalEarth shapefiles and then importing them in to a PostGIS database. It assumes that you have installed all the dependencies listed above:


Included data


We’ve prepped city labels with Dymo at several zoom levels so you don’t have to (it takes weeks). The resulting shapefiles (SHP and related extensions) should be imported into PostGIS for optimal performance and we include a script for that. The MML file assumes this step has been accomplished.

Also included are a dump of beta 1.5 Natural Earth roads for the mid-zooms. The import script pushes those into PostGIS, too.

Other Stuff


These are mostly just a bunch of vanilla shell scripts that handle the multi-step process of setting up a PostGIS database.


Leave a Reply

Your email address will not be published. Required fields are marked *