Created
March 31, 2015 23:04
-
-
Save SteveUpton/50c3819056b4a33e39cb to your computer and use it in GitHub Desktop.
Converts a CartoDB table generated from YB Tracking YML into a linestring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Generate the timestamp from the supplied data | |
UPDATE yb | |
SET timestamp=to_timestamp(SUBSTRING(name, 7, 20), 'DD-MM-YYYY HH24:MI:SS'); | |
-- Generate the linestring as a new table | |
CREATE TABLE yb_linestring AS ( | |
SELECT | |
ST_MakeLine(the_geom ORDER BY timestamp) AS the_geom | |
FROM yb); | |
-- Necessary to make the table appear on your CartoDB dashboard | |
-- (see: https://github.com/CartoDB/cartodb/wiki/creating-tables-though-the-SQL-API) | |
SELECT cdb_cartodbfytable('yb_linestring'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment