I’m generating a view using the query like this in CartoDB

SELECT table1.cartodb_id, table2.data_count, table2.event, table1.the_geom_webmercator FROM table1 JOIN table2 ON table1.data_id = table2.data_id

In my CartoCSS, I want to set the torque marker color conditionally. Both of the following fail.

['table2.data_count' < 10]{ marker-fill: #D6301D; } [data_count < 10]{ marker-fill: #D6301D; }

How can I set the CartoCSS to set marker color based on table2.data_count


1 Answer 1


CartoCSS, when used when Torque, doesn't know about your columns data. Filters cannot be used like your example:

['table2.data_count' < 10]{ marker-fill: #D6301D; }

in Torque because the different values you have wouldn't make sense for it.

The way that Torque works is with the aggregation function, that by default counts the number of events in the same location:

Map {
  -torque-resolution: 2;

The result of the torque-aggregation-function is the only variable that Torque knows about, the variable value that you can see if you apply a Torque Category map. In your case, you would have to replace this aggregation function by something that gives you the values of your load column.

This value variable can go from 0 to 255 because of certain limitations, so make sure that the aggregation function will return something bounded by these values.

If your "load" column does not exceed 255, you could try something like:


and then you should be able to use your filters like:

  [value <10] { marker-fill: #000; }
  [value < 8] { marker-fill: #400; }
  [value < 3] { marker-fill: #800; }
  [value <= 1] { marker-fill: #F00; }

You can learn about the details on how spatial aggregation works here.


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.