I'm trying to style a torque heatmap in Cartodb based on a weighting value(pntcnt) rather than sum of points in an area. I think i've generated the appropriate value with the -torque-aggregation-function:"sum(pntcnt)";

However I can't seem to get the styling right.

I am new to CartoDB.

Full CSS code.

Map {

  image-filters: colorize-alpha(blue, cyan, #008000, yellow , orange, red);
  marker-file: url(http://s3.amazonaws.com/com.cartodb.assets.static/alphamarker.png);
[value > 500] { marker-fill: blue; }
[value > 1000] { marker-fill: cyan; }
[value > 1500 an] { marker-fill: yellow; }
[value > 2500 { marker-fill: red; }

Data look something like this

Cartodb_ID        the_Geom                  pntcnt
7384             -107.6227, 24.4173         3391
7476             -107.6140, 24.4219         2514
6481             -107.7091, 24.4809         2352
6572             -107.7004, 24.4764         2258

2 Answers 2


You could use a query like:

WITH aux AS (
  SELECT max(pntcnt) AS m
  FROM table_name
  (100.0*pntcnt)/aux.m AS norm_pntcnt
  table_name t,

to have a norm_pntcnt column with 0-100 values. Then in the CartoCSS, you could use something like:

/** torque_heat visualization */

Map {

  image-filters: colorize-alpha(blue, cyan, lightgreen, yellow , orange, red);
  marker-file: url(http://s3.amazonaws.com/com.cartodb.assets.static/alphamarker.png);
  marker-fill-opacity: 0.4*[value];
  marker-width: 36;
#populated_places[frame-offset=1] {
#populated_places[frame-offset=2] {

You could also play with -torque-resolution and marker-width to adjust the map to your preferences.


The Torque value variable range is limited from 0 to 255 at the moment, and your data seem to contain values much higher than this threshold.

You might want to normalize the data in the aggregation function or divide it by some quantity so that this value gets smaller (sum(pntcnt)/100). Depending on the nature of your data, just play with it and make sure that your aggregation function does not return values bigger than 255.

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.