Created
March 11, 2021 12:01
Revisions
-
geobabbler created this gist
Mar 11, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ SELECT ARRAY_TO_STRING(ARRAY_AGG(CONCAT(st_x(q.loc),',',st_y(q.loc))), ';') AS coords FROM ( WITH DATA AS ( SELECT loc, resource_id, wkt, capture_date, (LAG(capture_date) OVER (PARTITION BY resource_id ORDER BY capture_date ASC)) AS prev_date, (LAG(wkt) OVER (PARTITION BY resource_id ORDER BY capture_date ASC)) AS prev_loc FROM ( SELECT resource_id, loc, st_astext(loc) AS wkt, capture_date FROM `my_project.my_dataset.geo_sample` ORDER BY capture_date DESC) q ORDER BY capture_date ) SELECT 'Sample Asset' AS name, resource_id, loc, capture_date FROM DATA WHERE wkt<>prev_loc ORDER BY capture_date ASC) q