<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Distance between two Geocoordinates in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Distance-between-two-Geocoordinates/m-p/422517#M121323</link>
    <description>&lt;P&gt;Thanks .Will try both options.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jun 2019 18:46:47 GMT</pubDate>
    <dc:creator>srs20</dc:creator>
    <dc:date>2019-06-14T18:46:47Z</dc:date>
    <item>
      <title>Distance between two Geocoordinates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Distance-between-two-Geocoordinates/m-p/422514#M121320</link>
      <description>&lt;P&gt;I'm trying to find the distance between two geo coordinates and am looking for help with the search syntax.Here's what my data looks like&lt;BR /&gt;
Index=S1 created from Sensor1.csv has Id,Lat1,Long1 and Index=S2 created from Sensor2.csv has Id,Lat2,Long2 . I need to find all Lat2 and Long2 that are within a certain distance (say 1 mile) of Lat1 and Long1. I'm ok to do something  like the calculation below because I'm working in a small area and reasonable accuracy will work ..is the search syntax below correct?&lt;/P&gt;

&lt;P&gt;index=S1 or index=S2 | eval distance=sqrt(pow(Lat1-Lat2,2)+pow(Long1-Long2,2)) ....&lt;/P&gt;

&lt;P&gt;How would I use the Haversine formula (assuming I convert my lat long to the required x,y format that Haversine needs)&lt;/P&gt;

&lt;P&gt;How do I use the calculated distance in my search syntax. Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 22:53:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Distance-between-two-Geocoordinates/m-p/422514#M121320</guid>
      <dc:creator>srs20</dc:creator>
      <dc:date>2019-06-13T22:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Distance between two Geocoordinates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Distance-between-two-Geocoordinates/m-p/422515#M121321</link>
      <description>&lt;P&gt;Hi srs20,&lt;/P&gt;

&lt;P&gt;you can use this macro in macros.conf :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[distance(4)]
args = lat1,lon1,lat2,lon2
definition = eval rlat1 = pi()*$lat1$/180, rlat2=pi()*$lat2$/180, rlat = pi()*($lat2$-$lat1$)/180, rlon= pi()*($lon2$-$lon1$)/180\
| eval a = sin(rlat/2) * sin(rlat/2) + cos(rlat1) * cos(rlat2) * sin(rlon/2) * sin(rlon/2) \
| eval c = 2 * atan2(sqrt(a), sqrt(1-a)) \
| eval distance = 6371 * c |  fields - a c r*
iseval = 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;it can then be used in the SPL like this: &lt;CODE&gt;| distance(lat1,lon1,lat2,lon2)&lt;/CODE&gt; (sorry not able to add the tick-thingy around the macro).&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 23:17:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Distance-between-two-Geocoordinates/m-p/422515#M121321</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-06-13T23:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Distance between two Geocoordinates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Distance-between-two-Geocoordinates/m-p/422516#M121322</link>
      <description>&lt;P&gt;There are several apps for that:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://splunkbase.splunk.com/apps/#/search/haversine/"&gt;https://splunkbase.splunk.com/apps/#/search/haversine/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 23:59:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Distance-between-two-Geocoordinates/m-p/422516#M121322</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-13T23:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: Distance between two Geocoordinates</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Distance-between-two-Geocoordinates/m-p/422517#M121323</link>
      <description>&lt;P&gt;Thanks .Will try both options.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 18:46:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Distance-between-two-Geocoordinates/m-p/422517#M121323</guid>
      <dc:creator>srs20</dc:creator>
      <dc:date>2019-06-14T18:46:47Z</dc:date>
    </item>
  </channel>
</rss>

