Created
January 22, 2024 20:02
-
-
Save hansthen/149a6e1ba20a79d2678705ce696cc5b2 to your computer and use it in GitHub Desktop.
jq for converting timedimension format to timeline format
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 characters
cat track_bus699.geojson | jq '[([.geometry.coordinates, .properties.times] | transpose | .[] | {"coordinates": .[0], "start": .[1]}) as $features | del(.geometry.coordinates, .properties.times) | .geometry += {"coordinates": $features.coordinates} | .properties += {"start": $features.start, "end": ($features.start | (gsub("\\s"; "T") + "Z") as $date | $date | fromdate | . + 2)}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cat track_bus699_iso.geojson | jq --arg duration 3 '.features[] |= [([.geometry.coordinates, [.properties.times[] as $times | $times | try (fromdate) catch $times]] | transpose | .[] | {"coordinates": .[0], "start": .[1]}) as $features | del(.geometry.coordinates, .properties.times) | .geometry += {"coordinates": $features.coordinates} | .properties += {"start": $features.start, "end": ($features.start | . + ($duration | fromjson) )}]'