Open Street Map with Tilemill (for beginners)
I’ve recently had to develop a mapping solution that needed to use Open Street Maps data in a MapBox style map (i.e. not Google Maps). There is a tool called TileMill from MapBox that is really great and allows you to style the map exactly the way you want it.
However I found it really tricky to figure out how to get the data you need in to the map. It took me a good day to figure it, so I though a simple guide would be useful for everyone else (and me next time I need to do it).
Hopefully you’ll fine it useful too.
A PostgreSQL database is required to hold the map data. I’ve used MySQL and MSSQL before so PostgreSQL is a bit odd to me. Don’t worry though, unless you need to do anything custom then you won’t need to do much with it manually.
Download the PostgreSQL app from http://postgresapp.com/.
2. Install osm2pgsql
The osm2pgsql extracts the data from Open Street Map (osm) files into the PostgreSQL database. Instructions to install it on various platforms can be found at http://wiki.openstreetmap.org/wiki/Osm2pgsql. The Mac OSX install is straightforward from Binary, the link is also on this page.
3. Download Open Street Map data
My advice on this is don’t download more than you need to, some of the files are huge. The full world of data is currently 23Gb. Not only does it take a while to download, it also takes even longer to process. I tried processing the planet OSM and it was still running 18 hours later. Probably better to do it one country or continent at a time.
I found two sources of data; the first from Open Street Map (http://wiki.openstreetmap.org/wiki/Planet.osm) and the with more specific country breakdowns (http://download.geofabrik.de/). Download the .osm.pbf files, they work well.
4. Open psql command line
If you have installed PostgreSQL correctly, on Mac OSX at least, you should have a little elephant in your top bar (or elsewhere on other OS). From the elephant select open pqsl. This will open up a new psql terminal/command prompt where you should run the following (one line at a time);
CREATE EXTENSION postgis;
CREATE DATABASE osm;
CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
This creates a new extension for the postgis dta, then creates a database called osm, switches to that database using the \c and then sets the postgis schema to it.
5. Open a new terminal/command window
Now you can extract the data from the osm files into the PostgreSQL database. Run the following (one line at a time);
cd [location of your opm files]
osm2pgsql -U yourusername -H localhost -P 5432 -d osm -C 32000 xxxx.osm.pbf
Remember to change your username [mac user] and the filename.
This should start processing the data and will show you some progress, though not a % complete. Just wait now!
6. Download Open Streets Style
Download or clone the Open Streets Style project from https://github.com/mapbox/open-streets-style. This is a project you can open in TileMill that has pretty much all the data you’ll need loaded in and styled for you, which you can then customise using Carto.
Once downloaded move it into your Mapbox projects folder, on a Mac this is in ~/Documents/Mapbox/projects. The configue.py file sits directly in the projects folder.
You shouldn’t need to edit the configure.py file, but you will need to run the file from a terminal window.
7. Download Layers
Download the files http://tilemill-data.s3.amazonaws.com/osm/processed_p.zip and http://tilemill-data.s3.amazonaws.com/osm/shoreline_300.zip and extract them. Then copy the files out of the folders into the open-streets/layers folder in the Mapbox project.
8. Open TileMill and open the open-streets project
It may take a minute or two to open but hopefully you should see some streets for the area you wanted?
I hope you do because I can’t offer much more advise. It took me ages to get this far.
Thomson Holiday Design Stores
We developed the first of these award winning interactive travel experiences and now support a growing network of stores.
Onto the High Street: Event Wrap Up
Omnifi were proud to sponsor the latest TLA Retail Tech event looking at eCommerce brands who are investing in physical retail.
Award winners with Be At One
We've been crowned award winners with Be At One by the Restaurant Marketer & Innovator awards.