Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gagecarto/8508509 to your computer and use it in GitHub Desktop.
Save gagecarto/8508509 to your computer and use it in GitHub Desktop.
This guide documents the steps I used to get OSM Bright successfully loaded in TileMill v.0.10.1 on Windows 7 Enterprise SP1
Required software:
Python (2.7 for me)
TileMill v.0.10.1 ( https://www.mapbox.com/tilemill/ )
OpenGeo Suite 4.0.1 (uses PostgreSQL 9.3rc1). OpenGeo suite isn't a hard requirement here. There are other ways to install postgres/PostGIS. This just seemed like the quickest and easiest way to get up and running. I installed to the default location and also installed Client Tools for PostGIS, pgAdmin and GDAL though these are likely not prerequisites. ( http://boundlessgeo.com/solutions/opengeo-suite/download/ ) Note: Name and e-mail registration is required to download.
osm2pgsql ( http://customdebug.com/osm/osm2pgsql.zip ). More info on osm2pqsql and Windows is here: http://wiki.openstreetmap.org/wiki/Osm2pgsql#Binary. I had success using the osm2pgsql_32bitId.exe binary. The default.style file wasn't included with the osm2pgsql binary but you can grab that from here: (https://github.com/openstreetmap/osm2pgsql/blob/master/default.style )
Also download the latest OSM Bright from Mapbox here: ( https://github.com/mapbox/osm-bright/zipball/master ) along with these three shapefiles:
http://tilemill-data.s3.amazonaws.com/osm/coastline-good.zip
http://tilemill-data.s3.amazonaws.com/osm/shoreline_300.zip
http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.3.0/physical/10m-land.zip
Be sure to move these shapefiles to the extracted OSM Bright folder (same dir as make.py).
And of course you will need a .osm.pbf extract. ( http://metro.teczno.com ) or ( http://download.geofabrik.de/osm/ ) are both good places to get these. Probably best to test this workflow with a smaller extract for starters.
Getting Started:
At this point if you have admin it's a good idea to add this to your path so that you can run psql.exe from anywhere:
C:\Program Files (x86)\Boundless\OpenGeo\bin;
Next be sure to start PostGIS if it isn't already running:
Start menu > All programs > OpenGeo Suite 4.0.1 > PostGIS > Start
To keep things simple I was running as localhost and user "postgres"
Setting up the database for OSM data:
In a cmd console:
psql -h localhost -U postgres -c "create database osm"
psql -h localhost -U postgres -c "\connect osm"
psql -h localhost -U postgres -d osm -c "CREATE EXTENSION postgis"
Import OSM data:
In a cmd console:
Note: your paths may be different depending on where you saved the binary, style file and your osm data
C:\osm2pgsql\x64\osm2pgsql_32bitId.exe -H localhost -U postgres -c -s -G -d osm -C 2048 -S C:\osm2pgsql\default.style C:\osm2pgsql\rawdata\san-diego-tijuana.osm.pbf
Upon successful completion you should see a message similar to this:
Osm2pgsql took 89s overall
Setting up OSM Bright
Navigate to the Mapbox OSM Bright folder that was extracted and make a copy of configure.sample.py and rename it as configure.py
Open configure.py in an editor and change the following:
config["postgis"]["dbname"] = "your-database-name"
config["postgis"]["user"] = "postgres"
Optionally, change the project name:
config["name"] = "your-OSM-project-name"
Save and Exit
In a cmd console:
cd your-mapbox-osm-bright-folder
python make.py
You should see a message similar to this:
installing to /Documents/MapBox/project/your-OSM-project-name
The Windows workaround
The coastline-good.shp is fairly large (~300 MB) and seems to cause memory problems in the Windows version of TileMill. This is not an issue on Mac OSX or Ubuntu. The workaround is to manually extract coastline-good.shp and remove the reference to it in project.mml (see below). The project.mml file is located in your Documents\Mapbox\project\your-OSM-project-name folder and can be opened with an editor. After removing the reference to coastline-good.zip save the file and exit. Next open the project in TileMill. Once loaded you can manually add the coastline-good.shp as a layer. To do this, choose the "Layers" icon in the lower left corner. Add Layer, set the ID to be processed_p and the SRS to 900913 and Save (not Save & Style). Drag the processed_p layer to the bottom of your list and you should be set.
Note: You shouldn't need to manually extract the other shapefiles since TileMill will handle that once you open the project for the first time.
This is what should be removed from project.mml
{
"Datasource": {
"file": "C:\\osm2pgsql\\mapbox-osm-bright-sandiego\\coastline-good.zip"
},
"class": "shp",
"geometry": "polygon",
"id": "processed_p",
"name": "processed_p",
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
"srs-name": "900913"
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment