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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...