Daily Archives: February 8, 2012

TileMill, Carto and the Transport Map

A few months ago I started exploring some new technologies from DevelopmentSeed – namely Carto and TileMill. Carto is a CSS-style map description language, similar to Cascadenik, and TileMill is a browser-based application that lets you view maps while you’re designing them.

Initially my efforts were a complete flop – at that point neither Carto nor TileMill had any support for storing the map data in PostGIS, which is a key component of making maps from OSM data. A month later and support was added, so I got cracking – mainly bashing my head against the weirdness of the node package management system NPM. But after a lot of effort and only a little swearing, I got it all working. It’s totally worth it.

Making Maps with Tilemill

Designing maps is hard – both in the amount of complexity in the style rules (there’s lots of colours, widths and so on) and also in the data – every town is different, and the way a map looks varies wildly between town and countryside. So a key thing is to be able to iterate quickly, to make changes and to see how things look in different areas. My previous toolchain – effectively just a modified version of generate_image.py – was a complete pain. To check different areas I’d need to find out the coordinates, pick a zoom level, wait for the image, check it, rinse, lather and repeat. The power of having live-updating maps in TileMill is not to be underestimated!

My first map style produced with Carto and TileMill was the Transport layer. I had originally created the Transport layer using Cascadenik – similar to Carto, it’s a CSS-inspired approach to describing map styling, and much easier than writing individual symbolizers in XML. Carto takes the idea another step forward with sophisticated rules nesting, which I’ve been using more and more in recent months. Since porting the Transport layer, I’ve ported all my other styles to Carto, but more on that some other time. If you’re still creating mapnik style rules by editing XML, I’d advise you check out Carto instead!