0

I am trying to make a map that would show the total load of a bus. I have plotted the route and set up the time constraints. The ellipse is moving and seems to work fine, but when I try to style the ellipses based on the amount of load the marker-fill is completely removed.

Has anyone had this problem before?

/** torque visualization */

Map {
  -torque-aggregation-function:"round(avg(load))";
  -torque-resolution: 2;
}

#table_14{
  comp-op: lighter;
  marker-fill-opacity: 0.9;
  marker-line-color: #FFFFFF;
  marker-line-width: 0.5;
  marker-line-opacity: 1;
  marker-type: ellipse;
  marker-width: 6;

}
#table_11
  [value >10] { marker-fill: #000; }
#table_11
  [value > 8] { marker-fill: #400; }
#table_11
  [value > 3] { marker-fill: #800; }
#table_11
  [value > 0] { marker-fill: #F00; }

Table

map

1

CartoCSS, when used when Torque, doesn't know about your columns data. Filters cannot be used like that 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-aggregation-function:"count(cartodb_id)";
  -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 due to the way it is specified right now, 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:

  -torque-aggregation-function:"round(avg(load))";

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

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

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

  • I have made changes to the code that are displayed above. I see what you are saying about how the points generally compound in order display values, but pointing to the "load" column doesn't seem to work. Could you explain what you mean by my load column exceeding 255? The values in the column only go up to 14 and there are only 250 rows. – AvidDabbler Jan 4 '16 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.