I cannot figure out how to use the torque map:

A typical row of my data, which is named torquedata3, looks like : [nodenumber, lat,long,time,value].

I have multiple rows at the same time with each row having a different "value" ranging from 0-7. I simply want to display at each different node a different color depending on the value.

Sorry for how easy my question may seem but I can not get it to work, I have tried all sorts of different torque-aggregation-functions(avg, round(avg()), min, max, count).

Below is the code I am using (field 4 has the time and field_5 has my values I want to display).

/** torque visualization */

Map {






  marker-width: 4;

  [value = 0] { marker-fill: #229A00; }

  [value = 1] { marker-fill: #0F3B82; }

  [value = 2] { marker-fill: #7B00B4; }

  [value = 3] { marker-fill: #000000; }

  [value = 4] { marker-fill: #FF2900; }

  [value = 5] { marker-fill: #CC4C02; }

  [value = 6] { marker-fill: #993404; }

  [value = 7] { marker-fill: #662506; }


I am now trying to create a heatmap.

I have changed some of the commands to

Map {

  image-filters: colorize-alpha(red); 
  marker-file: url(http://s3.amazonaws.com/com.cartodb.assets.static/alphamarker.png);
 marker-width: 5;

But I cannot do this multiplication on the value, I get the error message: Invalid value for marker-fill-opacity, the type float is expected. 0.5*[value](of type field) was given. I would like to use the marker file that fades in order to get a heat map type visual as opposed to the dots that do not fade into each other as much.

  • Hi there, welcome to GIS stack exchange. I formatted your code using the CODE tag for easier readability. Jul 14, 2016 at 4:17

1 Answer 1


I have replicated your dataset according to your description (I highly recommend next time give us the link anyway). Here is my dataset, called new_table. It contains the following columns: cartodb_id(numeric), the_geom(geometry/points), city(string) and country(string), order_num(numeric, this should be your field_4) and colors(numeric, and this should be as field_5).

If you select Torque Map in CARTO Wizard and change the CartoCSS a little bit in order to add the colors, you end up with a block of CartoCSS code like this:

/** torque visualization */

Map {

  comp-op: lighter;
  marker-fill-opacity: 0.9;
  marker-line-color: #FFF;
  marker-line-width: 0;
  marker-line-opacity: 1;
  marker-type: ellipse;
  marker-width: 6;
  marker-fill: #0F3B82;
#new_table[frame-offset=1] {
#new_table[frame-offset=2] {

  [value = 1] { marker-fill: #FFCC00; }

  [value = 2] { marker-fill: #FFA300; }

  [value = 3] { marker-fill: #FF5C00; }

  [value = 4] { marker-fill: #FF6600; }

  [value = 5] { marker-fill: #FF2900; }

  [value = 6] { marker-fill: #F11810; }

  [value = 7] { marker-fill: #B40903; }


I have reused the code from this gist (where I also add a bubble effect), and this is the resulting map.

Take good care to set torque-time-attribute parameter to your date or numeric field that you want your data-points to be ordered. In addition, you should set torque-aggregation-function attribute to other aggregation operation but count. What Torque.js is doing is aggregating in a third dimension (usually time) and apply that formula. So if you use count with just 7 rows with different values, you will end up with value equal to 1 each time/bin.

  • Thank you that seemed to work. I also read somewhere that [value = 0] does not work, is this true? Some of the elements in my field_5 are valued 0.
    – Michael
    Jul 14, 2016 at 16:33
  • The value 0 does not work with count aggregation function, because you always get more than one figure. Last, if your question has been answered, please set as answered. Jul 14, 2016 at 16:45

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.