So! Really basic question. I want to make a Torque map – easy enough – but I want it to display the various datapoints in different colors depending on the value of annual_irr.

Here's what I thought I'd enter into the cartocss editor to make it work (where annual_irr is a number from -.06 to .24), but this just displays the datapoints with no color at all:

Map {

  comp-op: lighter;
  marker-fill-opacity: 0.9;
  marker-line-color: #FFF;
  marker-line-width: 1.5;
  marker-line-opacity: 1;
  marker-type: ellipse;
  marker-width: 6;
  [ annual_irr <= 1 ] { marker-fill: #1a9850; }
  [ annual_irr <= 0.1 ] { marker-fill: #fff2cc; }
  [ annual_irr <= 0 ] { marker-fill: #d73027; }

Any idea what I'm doing wrong? Why isn't the CartoDB thingy interpreting the annual_irr marker-fill rules correctly?

1 Answer 1


You can't directly use column names in Torque's CartoCSS like you can with other types of maps. Instead, you need to let the torque-aggregation-function do the work for you. This function outputs a number called value that you can later use in the CartoCSS.

It might seem weird to do it this way, but Torque bins data in time and space and then uses the aggregation function you use in that argument to output a value. For instance, if there are four events in a bin in num_column that are 2,4,6, and 8, count(num_column) would output 4, sum(num_column) would output 20, avg(num_column) would output 5, etc. So you need to decide which aggregation function to use. They're PostgreSQL functions.

So in your case, maybe average is best? You would change count(cartodb_id) to avg(annual_irr),

and later in the CartoCSS, change annual_irr to value, and the numbers in the conditions to something appropriate for what you would expect in a cell. Reducing the resolution to 1 means you have very small bins and your map will be closer to a normal marker-based map.

You can read more about how it works here.

Hope that helps!

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.