Tuesday, March 12, 2013

Automating Maperitive generation and MapBox upload

I recently blogged about integrating MapBox maps within the Smallworld GIS.  I included a video clip that showed how I connected Smallworld to contour and hillshading maps hosted on MapBox.  Those contour and hillshaded maps were created using Maperitive.  In this post, I want to share how I automated the generation and upload of these maps.

If you are familiar with Maperitive you will know that it has had a scripting language for a long time and recently it also introduced Python scripting.  For this post I am still using the old scripting framework.  I imagine it can easily be ported to Python.

The Maperitive script references some custom rulesets that I created to allow me to explicitly style the contour lines.  Following is the code I used to automate map generation and upload.


  • contours-white.mrules
    • a Maperitive ruleset styling white contour lines with transparent background
  • contours.mrules
    • a Maperitive ruleset styling brown contour lines with transparent background
  • contours.mscript
    • the Maperitive commands required to generate brown contours, white contours and hillshading.  Note that color-depth=32.  This is required to allow transparent backgrounds in the tiles stored in the MBtiles database
  • create_and_upload.bat