Skip to content

Instantly share code, notes, and snippets.

@peterdesmet
Last active January 4, 2016 02:29
Show Gist options
  • Save peterdesmet/8555766 to your computer and use it in GitHub Desktop.
Save peterdesmet/8555766 to your computer and use it in GitHub Desktop.
CartoDB CSS and SQL to visualize flight tracks of gull Eric grouped by seasonal behaviour in Torque. Expressing the seasonal behaviour as a number allows Torque to differentiate between those.
/** torque visualization */
Map {
-torque-frame-count:512;
-torque-animation-duration:40;
-torque-time-attribute:"date_time";
-torque-aggregation-function:"avg(behaviour_number)";
-torque-resolution:1;
-torque-data-aggregation:linear;
}
#bird_tracking{
comp-op: multiply;
polygon-opacity: 0.8;
line-color: #ffffff;
line-width: 1;
line-opacity: 1;
marker-opacity: 0.9;
marker-line-color: #ffffff;
marker-line-width: 0.5;
marker-line-opacity: 1;
marker-type: ellipse;
marker-width: 3;
marker-fill: #b81609;
[value >= 2] { marker-fill: #ff9900; }
[value >= 3] { marker-fill: #2167ab; }
}
#bird_tracking[frame-offset=1] {
marker-width:5;
marker-opacity:0.45;
}
#bird_tracking[frame-offset=2] {
marker-width:7;
marker-opacity:0.225;
}
SELECT
cartodb_id,
the_geom,
the_geom_webmercator,
date_time,
CASE
WHEN date_time >= '2013-05-28' AND date_time < '2013-06-25' THEN 1
WHEN date_time >= '2013-06-25' AND date_time < '2013-07-24' THEN 2
ELSE 3
END as behaviour_number
FROM bird_tracking
WHERE
device_info_serial = 851
AND userflag IS FALSE
AND date_time >= '2013-05-17'
AND date_time < '2013-12-19'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment