mapbox/tilemill — Issue #1324: marker size scaled proportionally to data values
Author: springmeyer
Created: 2012-02-26 00:20:48+00:00
State: open

TileMill should support data-driven "scalepoints", or circles whose radius changes in relation to underlying data attributes.

Currently you can use conditional styles like in this [tutorial](http://mapbox.com/tilemill/docs/crashcourse/styling/):

```css
#earthquakes {
[Magnitude >= 2.5] { marker-width:3; }
[Magnitude >= 3] { marker-width:4; }
[Magnitude >= 3.5] { marker-width:5; }
[Magnitude >= 4] { marker-width:6; }
[Magnitude >= 4.5] { marker-width:7; }
[Magnitude >= 5] { marker-width:8; }
[Magnitude >= 5.5] { marker-width:9; }
[Magnitude >= 6] { marker-width:10; }
}
```

And you can script the creation of these conditions, like discussed [here](http://support.mapbox.com/discussions/tilemill/329-symbolizing-point-data-proportionally).

But [ideally](https://twitter.com/#!/ChrisSpurlock/status/173463364171862016) we can support one-liners like:

```css
#earthquakes {
marker-width:[magnitude*2]; /* where 'magnitude' is an attribute with data values reasonable to be used for the size of the circle */
}
```

The solution here is easy - we simply need to provide a patch to Mapnik to make `marker-width` and or `marker-height` "expressions". The ticket for that upstream is at: https://github.com/mapnik/mapnik/issues/1102. Also see the similiar, but longer term upstream feature in Mapnik for supporting expressions in svg transforms: https://github.com/mapnik/mapnik/issues/664 and the Carto discussion on back compatibility of moving to expression types: https://github.com/mapbox/carto/issues/126