Splunk Search

How to calculate speed (distance/time) from latitude and longitude fields?

himynamesdave
Contributor

hi everyone,

looking for some best practice, advice, and awesomeness from you guys on this one.

has anyone ever tried calculating speed from lat / long fields in data?

for example, I have a .gpx data that looks like this:

<time>2015-02-27T09:03:01.000-07:00</time></trkpt>
<trkpt lat="43.58573655" lon="-110.82813699">
<ele>1930.0</ele>
<time>2015-02-27T09:03:02.000-07:00</time></trkpt>
<trkpt lat="43.58597959" lon="-110.82789655">
<ele>1918.0</ele>
<time>2015-02-27T09:03:18.000-07:00</time></trkpt>
<trkpt lat="43.5859905" lon="-110.82785591">
<ele>1918.0</ele>
<time>2015-02-27T09:03:19.000-07:00</time></trkpt>
<trkpt lat="43.58598692" lon="-110.8278205">
<ele>1918.0</ele>

fields = _time, lat, lon, ele

i want to calculate some basic metrics - average speed, top speed - and would love to hear opinions on searches to tackle this so I'm not reinventing the wheel.

in the future I will build in some playback element to view the route vs. speed in splunk but for now I just want to know how others have tackled this.

examples = kudos 🙂

thanks in advance!

-dave

1 Solution

jbjerke_splunk
Splunk Employee
Splunk Employee

Hi Dave

There is a custom Splunk command, haversine, that calculates the distance between two lon and lat points. You can download this command here:
https://apps.splunk.com/app/936/

After that you should be able to calculate the speed

speed=distance/delta-time

j

View solution in original post

himynamesdave
Contributor

Follow up blog post with some examples here: http://blogs.splunk.com/2015/03/22/downhill-splunking-part-1/

0 Karma

gfuente
Motivator

Hello

You could use the haversine app: https://apps.splunk.com/app/936/

It does works with 6.x, I tested it.

To get the distance between two points, and with the difference in the timestamps you could calculate the velocity between 2 coordinates

Regards

himynamesdave
Contributor

Hey Guillermo - thanks!

I was wondering wether you had built a search to calculate speed between each event when using this app? If so, what did it look like? I'm struggling to get one built that works well.

0 Karma

Imjusttesting
Explorer

@himynamesdave,

Any luck with calculating of speed ? I'm also looking for similar solution

0 Karma

jbjerke_splunk
Splunk Employee
Splunk Employee

Hi Dave

There is a custom Splunk command, haversine, that calculates the distance between two lon and lat points. You can download this command here:
https://apps.splunk.com/app/936/

After that you should be able to calculate the speed

speed=distance/delta-time

j

himynamesdave
Contributor

Hey Johan - thanks!

I was wondering wether you had built a search to calculate speed between each event when using this app? If so, what did it look like? I'm struggling to get one built that works well.

0 Karma
Get Updates on the Splunk Community!

Synthetic Monitoring: Not your Grandma’s Polyester! Tech Talk: DevOps Edition

Register today and join TekStream on Tuesday, February 28 at 11am PT/2pm ET for a demonstration of Splunk ...

Instrumenting Java Websocket Messaging

Instrumenting Java Websocket MessagingThis article is a code-based discussion of passing OpenTelemetry trace ...

Announcing General Availability of Splunk Incident Intelligence!

Digital transformation is real! Across industries, companies big and small are going through rapid digital ...