block by jczaplew d9aed1ecd082ad0eaf79

Rolling tiles with mapnik + tilestache instead of Tilemill

Rolling tiles sans Tilemill

Perhaps you’ve had problems programmatically creating tiles with Tilemill, or are concerned about the future stability of project (or you just like playing with geo software).

Install mapnik and TileStache

brew install mapnik --with-gdal --with-postgresql
sudo pip install -U PIL modestmaps simplejson werkzeug
git clone https://github.com/TileStache/TileStache.git TileStache
cd TileStache
python setup.py install

Export your Tilemill project

  1. Open your project in Tilemill
  2. Select “Export” -> “Mapnik XML”
  3. Save it to /TileStache/your_project.xml

Modify TileStache config

Modify /TileStache/tilestache.cfg to be similar to this:

{
  "cache":
  {
    "name": "Disk",
    "path": "my_cache",
    "umask": "0000",
    "dirs": "portable"
  },
  "layers": 
  {
    "your_layer": {
      "provider" : {
        "name": "mapnik", "mapfile": "your_project.xml"
      }
    }
  }
}

Test

Run the following:

./scripts/tilestache-server.py

Then open http://localhost:8080/your_project/preview.html in a web browser. If you see your map, you are good to go!

Other

Example: seed a cache from zoom levels 5-12 of the lower 48

sudo python ./scripts/tilestache-seed.py -b 24 -128 50 -66 -c tilestache.cfg -l your_project 5 6 7 8 9 10 11 12

tilestache-seed.py also has methods for exports to other formats, such as mbtiles and S3. Check out the documentation for more info.