I am making an animated layer and the values I want to map range are from 0-1, as a percentage (e.g. 0.33333). I'm trying to change the color and eventually size based on the value.

I tried adding conditional statement based on this example, but it looks like it is only picking up the first value. Maybe I don't understand the order the conditional statements are being evaluated. I'm adapting code from this example: Animating quantitative values in Carto Torque Cat?

Map {
  -torque-frame-count: 233;
  -torque-animation-duration: 30;
  -torque-time-attribute: "date";
  -torque-aggregation-function: "CDB_Math_Mode(value)";
  -torque-resolution: 4;
  -torque-data-aggregation: linear;
#layer[frame-offset=1] {
  marker-width: 8;
  marker-fill-opacity: 0.5;
#layer[frame-offset=2] {
  marker-width: 10;
  marker-fill-opacity: 0.25;
#layer [ value <= 1] {
  marker-fill: #21b100;
#layer [ value <= 0.8] {
  marker-fill: #E31A1C;
#layer [ value <= 0.6] {
   marker-fill: #FC4E2A;
#layer [ value <= 0.4] {
  marker-fill: #FD8D3C;
#layer [ value <= 0.2] {
  marker-fill: #FEB24C;

1 Answer 1


In order to create an animated map styling the points based on a field, you need to follow these steps:

  1. Go the layer STYLE tab and select Animated from the aggregation methods.
  2. Select date as COLUMN.
  3. Switch the slider from VALUES to CartoCSS (now the hacky part begins).
  4. Replace count(cartodb_id) with something like avg(avail_ratio*100). Click o APPLY.
  5. Remove the last two blocks of code if you do not want to have the halo/trace effect (optional).
  6. Add CartoCSS conditional blocks, but within the layer block. You will end up with something similar to this code.

And the result should be like this:


  • Thanks Ramiro. I was able to further refine my results into categories and it looks like it is working now. Commented Feb 12, 2018 at 15:52

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.