Skip to content

Instantly share code, notes, and snippets.

@javisantana
Created August 12, 2015 11:05
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save javisantana/be5daa426f1844009ef6 to your computer and use it in GitHub Desktop.
Save javisantana/be5daa426f1844009ef6 to your computer and use it in GitHub Desktop.
speed from a track table
WITH deltas as (
SELECT
st_distance(the_geom::geography, lag(the_geom::geography, 1) over(order by timestamp)) as ddist,
timestamp - lag(timestamp, 1) over(order by timestamp) as dt
from out_2 offset 1000
)
select avg(ddist/dt) as speed from deltas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment