An auxiliary repository for the the project Image and Map Embeddings
It contains a docker-compose script to create a container with Postgres11 & Postgis2_5
The script will create 4 databases inside the container with OSM data for the following cities:
- newyork
- pittsburgh
- bristol
- london
INSTRUCTIONS
- Install docker and docker-compose
- Clone this repository
- Copy pittsburgh.osm file into postgis folder (Not provided here, but can be downloaded online)
- Run docker-compose up
- When container is running, initiate a shell script by using the following command docker exec -ti <container_id> bash
- Run the script load_osm_data.sh inside the container to load OSM data into tables (This may take a while...) bash load_osm_data.sh
- Test the container (by using getMVT.py for example, and visualizing the result in qgis)
To check the databases do the following inside the container
- su postgres This will change user to postgres
- psql Use psql language
- \l Shows all the databases
- \c newyork Connect to NY's database
- \d Shows tables in the database
- select name from planet_osm_roads where name='Wall Street'; Do an example query
- \q quit database
- exit Exit container
Enjoy
Install mapnik and dependencies. A very good tutorial to follow is Installing an OpenStreetMap Tile Server on Ubuntu
- Ubuntu 18.04
- Mapnik 3.0.22 (check with mapnik-config -v)
- Ensure python bindings are installed by trying to import mapnik
- Carto (check with carto -v)
- 0.18.2
To render maptiles once that mapnik and mapnik-python bindings have been installed do the next
-
Clone OpenStreetMap Carto style.
git clone --depth 1 --branch v5.1.0 https://github.com/gravitystorm/openstreetmap-carto.git
-
Edit the project.mml file from the gravitystorm directory to match the settings of the postgres database. Relevant lines are after line 32. They should look like:
-
host: "localhost"
-
user: "postgres"
-
password: "postgres"
-
dbname: "newyork" # Adjust to the name of your database.
Note If a custumized style is required modify the .mml file and its style classes defined in styles/*.mss files. Here it could be posible to remove text from map tiles but we did it modifying directly the xml file (see step 5).
-
Convert the style project_street2vec.mml file to xml using carto. The xml file should be stored in the gravitystorm directory created in the first step.
carto -a "3.0.20" project.mml > style.xml
-
To remove all text and numbering from map tiles use the "removeTextXML" function defined in the script utils/carto.py.
-
Go to the utils/render_tiles.py script and configure relevant lines. (save directory, zoom levels and xml style file). Then run the script.