I'm playing around with an idea for reducing the size of my tilecache (inspired by this FOSS4G talk: http://vimeo.com/106873780.

The main idea is to define a set of tiles related to a bounding box, and I've made a small Python-script to calculate exactly what tiles I need (ie a list of tiles indexed by x, y and zoom), this can be found here: https://github.com/atlefren/ToPHR

Now: what I want to do is use TileMill to generate exactly the tiles i've found that I need, but I cannot find a way to throw a list of x,y,z at tilemill and make it render them.

I've looked at the command line export options: https://www.mapbox.com/tilemill/docs/manual/exporting/#exports-from-the-command-line, and I've even tried changing some of the code in tilelive (which actually does the rendering), but I cannot get this to work (I can limit what tiles are generated by editing a bunch of internals, but then the offsets in the resulting .mbtiles db seems to be off, probably related to metatiling, can provide examples here if wanted).

So: the question boils down to:

Is it possible, using some kind of parameter to index.js export, pass a list of x,y,z and render only those tiles? If not, how to go about forking tilemill and/or tilelive to make this possible.

Or, alternatively: how could I achieve this in a better way?

All suggestions are welcome, but I need a programmatic solution.

1 Answer 1


I've found a solution that seems to work.

After trying to find an explanation of the different parameters to the index.js export command i found that I had to go to the source.

I figured that the option

--list=[file]   Provide a list file for filescheme render. (Default: false)

Could be what I was after. After digging a bit through the tilemill and tilelive source code i found that this options is (not suprisingly) used by the filescheme renderer (it says that in the comments).

What I couldn't find was any documentation on the format on this file, but the tilelive repo had some text fixtures, namely: https://github.com/mapbox/tilelive.js/blob/master/test/fixtures/filescheme.json and https://github.com/mapbox/tilelive.js/blob/master/test/fixtures/filescheme.flat

I'm rather suprised that the .json format isn't valid json (note that the POJOs are just line separated), and I'm not quite sure on the ordering of x,y,z in the flat file, but i decided to try using the filescheme.json file as is as an input:

node /usr/share/tilemill/index.js export world ~/Documents/MapBox/export/file2.mbtiles --scheme=file --list=filescheme.json

This did create the ~/Documents/MapBox/export/file2.mbtiles file, and on closer inspection (using sqlite3) it seems to contain those tiles specified in filescheme.json:

sqlite> select * from tiles;





I haven't really tested if this mbtiles file is valid and working, but I expect it to do so. Hope someone finds this answer if they are facing the same issues, and that maybe the tilemill/tilelive developers spends some time documenting this (that is; id TileMill is still alive)

EDIT: after testing a bit I can confirm that the .mbtiles file generated this way works fine!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.