The following step-by-step procedure can be used to install Tilemill on a Windows PC. It has been tested on Windows 7 32-bit and Windows 7 64-bit.1
Tilemill was the original tool for the development of the openstreetmap-carto style. It supports both Linux and Windows (win32 and win64). Anyway, TileMill for Windows is no longer in active development: it hosts a very old version of Mapnik/node-mapnik. At the moment, the suggested tool for the autohoring of OpenStreetMap stylesheets is Kosmtik, which needs Mapnik 3 and recent versions of node-mapnik that at the moment cannot be installed on Windows 2; anyway, a Docker installation of Kosmtik can be run with Windows 64-bit.
Even if you should accomplish its installation on Windows through this manual, consider that:
Prefer direct Internet connection for the installation, avoiding the need of a proxy. At the end of the installation procedure (and DB population), Tilemill can run openstreetmap-carto off-line.
Before all, check whether your computer is running a 32-bit version or a 64-bit version of the Windows operating system: https://support.microsoft.com/en-us/kb/827218
When downloading the software reported in this procedure, always verify that you are selecting the appropriate Windows architecture: 32-bit (x86) or 64-bit (x64).
Install Tilemill; the latest working version at the moment should be http://tilemill.s3.amazonaws.com/dev/TileMill-v0.10.1-291-g31027ed-Setup.exe
Even if Tilemill has a GitHub repository including the most recent updates, with Windows it is suggested to proceed with the standard setup, which automatically installs and configures Mapnik/node-mapnik. A procedure to upgrade Tilemill and Mapnik over Windows without recompiling is not currently documented.
Download PostgreSQL (avoid using beta versions as also PostGIS shall be needed (check first the PostGIS compatibility with the version you are going to download):
http://www.enterprisedb.com/products-services-training/pgdownload#windows
For instance: postgresql-9.5.3-1-windows-x64.exe (for a Windows 64 bit system)
Use the following configuration steps for PostgreSQL:
Installation of PostGIS:
Open pgAdmin and store the above mentioned password.
Open a CMD (Command Prompt). Change directory (cd) to %programfiles%\PostgreSQL\*version*\bin
(e.g., cd C:\Program Files\PostgreSQL\9.5\bin
) and run these commands:
setx PGHOST localhost
setx PGPORT 5432
setx PGUSER postgres
setx PGPASSWORD postgres_007%
The above mentioned commands are needed by Tilemill to connect to the PostgreSQL db with the default settings of openstreetmap-carto.
Notice that ‘setx’ should be used to configure variables (defining variables with ‘set’ before invoking tilemill.exe will not work).
psql --help (to verify that psql works)
psql -h localhost -U postgres -c "create database gis"
psql -h localhost -U postgres -c "\connect gis"
psql -h localhost -U postgres -d gis -c "CREATE EXTENSION postgis"
psql -h localhost -U postgres -d gis -c "CREATE EXTENSION hstore"
Notice that, in order to get compatibility with project.yaml, the dbname shall remain “gis” and cannot be changed via the variables.
NOTE: To drop the database, in case of full data refresh, you can perform:
psql -h localhost -U postgres -c "drop database gis"
Then all creation commands must be issued again.
You need to download an appropriate .osm or .pbf file to be subsequently loaded into the previously created PostGIS instance via osm2pgsql
.
There are many ways to download the OSM data.
The reference is Planet OSM.
It’s probably easiest to grab an PBF of OSM data from geofabrik.
Also, BBBike.org provides extracts of more than 200 cities and regions world-wide in different formats.
Examples:
Map data of the whole planet (32G):
wget -c https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf
Map data of Great Britain (847M):
wget -c https://download.geofabrik.de/europe/great-britain-latest.osm.pbf
For just Liechtenstein:
wget https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf
wget https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf.md5
# Optionally, the following will xheck that the download wasn't corrupted:
md5sum -c liechtenstein-latest.osm.pbf.md5
Another method to download data is directly with your browser. Check this page.
Alternatively, JOSM can be used (Select the area to download the OSM data: JOSM menu, File, Download From OSM; tab Slippy map; drag the map with the right mouse button, zoom with the mouse wheel or Ctrl + arrow keys; drag a box with the left mouse button to select an area to download. The Continuous Download plugin is also suggested. When the desired region is locally available, select File, Save As, <filename>.osm
. Give it a valid file name and check also the appropriate directory where this file is saved.
In all cases, avoid using too small areas.
OpenStreetMap is open data. OSM’s license is Open Database License.
Download osm2pgsql for Windows (https://wiki.openstreetmap.org/wiki/Osm2pgsql#Windows):
https://lists.openstreetmap.org/pipermail/dev/2013-February/026525.html
https://github.com/openstreetmap/osm2pgsql/issues/17
Check the appropriate version running on your OS architecture.
Put it to the same directory of the saved .osm file
Install Python 2.7 from https://www.python.org/downloads/
Run the setup: when it comes to the point of adding environment variables, say Yes.
Python is needed to convert project.yaml (from openstreetmap-carto) to project.mml (that can be opened by Tilemill). It is also needed to download the shapefiles.
Open https://github.com/gravitystorm/openstreetmap-carto and press “Download ZIP”
Save it to %USERPROFILE%\Documents\MapBox\project\
(this path should conform to Tilemill Settings: ~\Documents\MapBox
)
Unzip the downloaded file (e.g., to project\openstreetmap-carto-master
)
Tilemill/openstreetmap-carto will render data which are stored in the gis database.
Use osm2pgsql to upload the locally available OpenStreetMap data to PostgreSQL. Local data could be in .osm format or .pbf, which is a compressed version of .osm.
Open a CMD
Change directory to %USERPROFILE%\Documents\MapBox\project\openstreetmap-carto-master
Check that Python works with: python -V
(otherwise: set PATH=%PATH%;<python directory>
).
To create db tables, populate them and create some index run the following:
cd <directory where you saved the .osm file and osm2pgsql>
osm2pgsql.exe -H localhost -d gis -U postgres -s -c -G -k -C 800 -S %USERPROFILE%\Documents\MapBox\project\openstreetmap-carto-master\openstreetmap-carto.style --hstore --style openstreetmap-carto.style --tag-transform-script openstreetmap-carto.lua <filename>.osm
Notice that the suggested process adopts the -s
(--slim
option), which uses temporary tables, so running it takes more diskspace, while less RAM memory is used. You might add --drop
option with -s
(--slim
), to also drop temporary tables after import.
If a script file named openstreetmap-carto.lua
is available in the openstreetmap-carto folder, add the parameter --tag-transform-script <lua script>
. The command would become the following:
osm2pgsql -H localhost -d gis -U postgres -s -c -G -k -C 800 -S %USERPROFILE%\Documents\MapBox\project\openstreetmap-carto-master\openstreetmap-carto.style --tag-transform-script %USERPROFILE%\Documents\MapBox\project\openstreetmap-carto-master\openstreetmap-carto.lua <filename>.osm (or <filename>.osm.pbf)
Notes:
<filename>.osm
with the saved .osm file (e.g., produced through JOSM); also <filename>.pbf
can be used;If still you fail to connect to the database, try editing %programfiles%\PostgreSQL\*version*\data\pg_hba.conf
and changing all md5
with trust
Note to create the indexes (which could slightly speed up db access):
%USERPROFILE%\Documents\MapBox\project\openstreetmap-carto-master\scripts\indexes.py | "C:\Program Files\PostgreSQL\<version>\bin\psql" -h localhost -U postgres -d gis
alternatively:
"c:\Program Files\PostgreSQL\<version>\bin\psql" -h localhost -U postgres -d gis -f indexes.sql
Create a folder to place shapeindex.exe.
Download the Win32 ZIP package of Mapnik from http://mapnik.org/pages/downloads.html (other Shapeindex link), open it with 7Zip (install it from http://www.7-zip.org) and extract shapeindex.exe
; move this file and all related DLL files to the previously created folder. This is needed by get-shapefiles.py
to speed-up the access to the shapefiles. Notice that the DLL files can be found in the lib directory of the ZIP file; all them have to be saved to the bin directory together with shapeindex.exe
.
Set the PATH appropriately:
set PATH=%PATH;<shapeindex folder>
Verify that the shapeindex command works with shapeindex –V
Now run:
cd %USERPROFILE%\Documents\MapBox\project\openstreetmap-carto-master
scripts\get-shapefiles.py
Wait for the completion of the entire process (e.g., “done!”)
OpenStreetMap Carto uses a YAML file for defining layers, named project.mml. TileMill does not directly support YAML, so rename the YAML file project.mml to project.yaml, download the latest version of the conversion script yaml2mml.py (which is no more inluded in the openstreetmap-carto maaster repository), move it to the script directory of your repository and run scripts\yaml2mml.py
to create a JSON format that TileMill can process. To achieve this, follow these steps:
python -m pip install --upgrade pip
Check that pip works with pip –V
. (Check also Scripts\pip
if pip is not found).
pip install pyyaml
ren project.mml project.yaml
Download yaml2mml.py from here or here (open the link with your browser, then save the page/file with name yaml2mml.py inside the script directory of openstreetmap-carto.
Your source project file will became project.yaml.
After a modification to project.yaml
, you need to run scripts\yaml2mml.py
so that a project.mml
in JSON format is created. This will allow TileMill to open the project.
scripts\yaml2mml.py
Alternatively to using yaml2mml.py, you can simply check the Python command described in the Editing Layers section of the CONTRIBUTING page of OSM-carto.
Notice again that you cannot contribute to openstreetmap-carto by using Tilemill3:
Revise all points.
Check in detail the content of INSTALL.md.
The application needs a few seconds to start, so be patient.
Select project Openstreetmap Carto
Give TileMill the time to render the map: accessing the database and rendering images is often a slow process (mainly depending on the amount of data to be managed, but also on the server performance and on the network), so give many seconds to TileMill to output or refresh the map.
Zoom out to the entire world shape (zoom level 1 or to some close zooms like zoom 4), then progressively zoom into the region where you downloaded the map data. You might use the double click and wait for the next zoom level to appear.
On the right pane, it is normal that only the first 4 tabs are displayed; this is an issue of the installed old TileMill version. (Check this note)
You shouldn’t use the text editor built-in to TileMill. Instead, hide the right pane and use an external text editor.
TileMill automatically refreshes the rendering upon any file change, including all .mss and project.mml.
With your browser, access the map through http://localhost:20009
To directly access the project: http://127.0.0.1:20009/#/project/openstreetmap-carto
Notice that Https will not work (use http instead).
View the changes in Tilemill
project.yaml
, you need to run scripts\yaml2mml.py
Most of the documentation is taken from Rendering of OSM data on Windows - Quickstart. ↩
Mapbox Studio Classic uses a different rendering technology, not compatible with OpenStreetMap Carto. (With Windows, there might be a possibility to use command line tools, that are not comfortable for autohoring.) ↩