Skip to content
Martin Tesař edited this page May 3, 2015 · 6 revisions

To enable rendering of our map, we must prepare geographic data in four steps:

  • Get planet shapefiles
  • Import OpenStreetMap data
  • Download and create height data
  • Configure mapnik style file

Prepare data structure

Create folder Data in the project root directory and two subfolders: shp and shadingdata.

Get planet shapefiles

Create directory world_boundaries, download planet shapefiles:

mkdir Data/shp/world_boundaries
cd Data/shp/world_boundaries
wget http://tile.openstreetmap.org/processed_p.tar.bz2
wget http://tile.openstreetmap.org/shoreline_300.tar.bz2
wget http://www.nacis.org/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip

Extract these files in this directory:

tar xvjf processed_p.tar.bz2
tar xvjf shoreline_300.tar.bz2
unzip ne_110m_admin_0_boundary_lines_land.zip

Import OpenStreetMap data

Open file mtbmap/settings/local.py, edit variables prefixed with OSM_* and OSM2PGSQL_* according to your system configuration. Choose any data source you want. Anyway, import can take huge amount of time. I recommend some small and well mapped area for testing purposes. For example extract of German region Saarland here: http://download.geofabrik.de/europe/germany/saarland-latest.osm.pbf. Import should take up less than 5 minutes:

python manage.py update_rendering_data

The same command is used to reimport data again, old records are deleted. There are plenty of other OSM data extracts from Geofabrik. If you cannot find one that suits your needs, use Osmosis to create any extract you want.

Download and create height data

Data for altitude profiles

Generating of altitude profile needs old SRTMv2 data. You can download it from http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/

Save these height files in the directory Data/shadingdata/SRTMv2. Don't extract ZIP files. Override variable SRTM_DATA from base.py in local.py if necessary. For Saarland, you will need only N49E006.hgt.zip and N49E007.hgt.zip.

Hillshading, hypsometry, contours

This step is optional. Since it is a little bit complicated, you can render maps without hillshading and contours. Just erase/comment layers with names hypsometry*, hillshade* and contours* (in fact, hypsometry and hillshade doesn't have to be erased, mapnik issues a warning).

Download

We use version 4.1 of SRTM files to generate hillshading, hypsometry and contours. Download it from ftp://xftp.jrc.it/pub/srtmV4/tiff/ to Data/shadingdata/SRTMv4.1. Again, if you want just data for our example - Saarland, download just srtm_38_03.zip

Create data

We don't have tutorial for this yet. You can have a look at files in height_data_processing app, but these are not up to date. You'd better look at OpenStreetMap Wiki and use tutorials from there. Search for Contours or Hillshading.

Configure Mapnik style file

Mapnik styles are located in styles/mapnik/my_styles. Update carefully all data sources in mapnik2normal.xml. Set correct database names and ports, paths to shapefiles and height files. You can do the same with mapnik2print.xml, but it can be done automatically later. Set database password entity in file ../inc/ent.xml.inc.

Create map image

You have all necessary geographic data for rendering uploaded in the database and on your hard drive. Try to render your first MTB map image, set lat, lon and zoom in render_map.py as you need:

cd styles/mapnik
python render_map.py

If everything goes well, you can see and open file map.png in the working directory.

Summary

You have downloaded, imported and created all necessary data for rendering and also height data to generate altitude profiles. Try this function in web browser (Routes -> Draw -> Create altitude profile). You can also try 'Export', just make sure to disable 'Legend' and 'Resolution for print'.

Next step is to create legend.