Friday, 29 April 2011

Installation of Carto Mapnik Style File Builder on Ubuntu

I find mapnik style files a bit clumsy to edit - lots of repetition that makes them hard to follow.
There are (at least) two utilities available that may make style file generation simpler.  These are Cascadenik and Carto.
It appears that Carto is being more actively developed at the moment, so I thought I would look at that first. Carto also reports to be much faster than Cascadenink.
The problem is that Carto is new-fangled and uses a javascript based language called node.js.   Despite my dislike of javascript, I thought I would persevere.  This is how I got it working on my Ubuntu 10.10 system:

  • Downloaded node.js version 0.4.7 from http://nodejs.org, and extracted it into /usr/local/node-v0.4.7.  Built with ./configure; make; make install.
  • Installed the node package manager npm using: curl http://npmjs.org/install.sh | sh
  • Installed carto dependencies:
    • npm install get     [used to be node-get, but the module has changed name]
    • npm install step
    • npm install srs
    • npm install underscore
    • npm install zipfile (actually did this twice because one of the document build actions failed on the first attempt...).
  • Downloaded carto using:  git clone https://github.com/mapbox/carto.git
  • No compilation necessary (it is javascript).  Executing cd carto; ./bin/carto gave no nasty errors, just "no input files", which looks promising.
I just need to work out how to use it now.

I have had a quick look at TileMill, which is a web based editor for carto stylesheets - it is very impressive - you can change the stylesheet and preview the map in real time.   The only problem that I have found with tilemill is that it does not seem to work with a postgresql database as the data source, which is where my OSM data is stored.  But at least I should get the idea about the structure of the files using that tool.

2 comments:

Anonymous said...

I got the error

Error: Cannot find module 'get'

Running

npm install get

fixed it.

Graham Jones said...

Thanks - I will correct it - node-get has changed its name to just 'get' since I wrote it.
Note that I have had trouble with the trunk carto code, and am having more success using the one that ships with tilemill at the moment...