Skip to content

Instantly share code, notes, and snippets.

@peterdesmet
Last active January 4, 2016 02:29
Show Gist options
  • Save peterdesmet/8555625 to your computer and use it in GitHub Desktop.
Save peterdesmet/8555625 to your computer and use it in GitHub Desktop.
CartoDB CSS and SQL to visualize flight tracks of gull Eric grouped by seasonal behaviour.
/** category visualization */
#bird_tracking {
line-width: 1;
line-opacity: 0.9;
}
#bird_tracking[behaviour="1. Egg incubation"] {
line-color: #b81609;
}
#bird_tracking[behaviour="2. Chick rearing"] {
line-color: #ff9900;
}
#bird_tracking[behaviour="3. Postfledging"] {
line-color: #2167ab;
}
SELECT
ST_MakeLine(the_geom_webmercator ORDER BY date_time ASC) AS the_geom_webmercator,
CASE
WHEN date_time >= '2013-05-28' AND date_time < '2013-06-25' THEN '1. Egg incubation'
WHEN date_time >= '2013-06-25' AND date_time < '2013-07-24' THEN '2. Chick rearing'
ELSE '3. Postfledging'
END as behaviour
FROM bird_tracking
WHERE
device_info_serial = 851
AND userflag IS FALSE
AND date_time >= '2013-05-17'
AND date_time < '2013-12-19'
GROUP BY behaviour
ORDER BY behaviour
/** category visualization */
#bird_tracking {
line-width: 1;
line-opacity: 0.9;
}
#bird_tracking[behaviour="1. Egg incubation"] {
line-color: #b81609;
}
#bird_tracking[behaviour="2. Chick rearing"] {
line-color: #ff9900;
line-comp-op: dst-over;
}
#bird_tracking[behaviour="3. Postfledging"] {
line-color: #2167ab;
line-comp-op: dst-over;
}
SELECT
ST_MakeLine(the_geom_webmercator ORDER BY date_time ASC) AS the_geom_webmercator,
CASE
WHEN date_time >= '2013-05-17' AND date_time < '2013-06-07' THEN '1. Egg incubation'
WHEN date_time >= '2013-06-07' AND date_time < '2013-07-21' THEN '2. Chick rearing'
ELSE '3. Postfledging'
END as behaviour
FROM bird_tracking
WHERE
device_info_serial = 801
AND userflag IS FALSE
AND date_time >= '2013-05-17'
AND date_time < '2013-12-19'
GROUP BY behaviour
ORDER BY behaviour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment