Skip to content

Map Styling in cascadenik, carto

nvkelso edited this page Jul 13, 2012 · 17 revisions

Implementing a map design:

  • Basic color choices are made in Photoshop, using a layered file.
  • Turn the design into computer syntax with a design markup language like Cascadenik or Carto.
  • Link the design up with the data thru uses of .class and #id on the layers.
  • Map preview rendering is performed by Mapnik.
  • Final tile renders (covered elsewhere)

Thematic Carto Tools

Build map legends (and stylesheets) based on data both quantitative and qualitative using Python-based Thematic Carto Tools

Stubs out MSS and MML files compatabile with Mapnik via Cascadenik or Carto based on a dataset for:

  • Quick data exploration of what's in a dataset
  • Refined cartographic presentations

Bonus: Will also build a legend in HTML format displaying the colors and bin labels.

Mapnik

Mapnik is the renderer for most open-source geo projects. But, raw Mapnik XML is crazy to read (let alone manually write). Enter: Cascadenik -&- Carto.

###Installation

###Documentation

###Background

Both are stylesheet renderers for Mapnik.

  • Carto is an evolution of the Cascadenik idea and language, with an emphasis on speed and flexibility.
  • MML for layer contents, MSS stylizes the features

Cascadenik

  • Styles map features using CSS and layer definitions
  • Cascading Style Sheets have given web pages pizzaz for 15 years.
  • CSS enables a separation between map layer .MML and their .MSS graphic appearance (it can easily be restyled)
  • Cascadenik is command line tool, 2 yrs old
  • Creates XML for Mapnik the 1st

Carto

  • Builds on Cascadenik’s CSS language
  • Can be used in TileMill from DevSeed
  • The MML file is JSON instead of XML (harder to comment)
  • Has arbitrary style attachments, cool!
  • Can use expressions in names, specifying font face and size.
  • Define variables in stylesheets, and use expressions to modify them.
  • Color swatches like @mybackground: #2B4D2D;
  • Then use it like: darken(@mybackground, 10%);
  • Creates XML for Mapnik the 2nd

###Workflow

to convert TileMill “carto” stylesheets to cascadenik / mapnik happiness

cd /Applications/mapbox-tilemill/

./bin/carto /path/to/project/style.mml

./tilemill.js

Note: adjust path as appropriate.

To see the end result of your CSS expanded:

cascadenik-style.py stylesheet.mss

Adjusting your styles thru multiple zooms

ScaleMaster Diagram

  • Scale Master - Interactive tool (Flash) and papers from Cindy Brewer at Penn state on what to include on your map, when.

  • Someday Carto will support CSS attr for grabbing the actual value out of a feature record.

Clone this wiki locally