<?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 Calculation using Latitude and Longitude in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/224296#M44580</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13069"&gt;@mjvincent87&lt;/a&gt; and &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1025"&gt;@jenkins_macedo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;another way of doing this is with column formula in a data table. try the following script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Clear Globals();
Names Default To Here( 1 );

// Open data file
dt = Open( "$SAMPLE_DATA/Cities.jmp" );

// add column for distance
dt &amp;lt;&amp;lt; New Column( "latrad", formula( :Latitude * (Pi() / 180) ) );
dt &amp;lt;&amp;lt; New Column( "longrad", formula( :Longitude * (Pi() / 180) ) );

dt &amp;lt;&amp;lt; New Column( "Distance", Numeric,
	formula(
		6371.00 * 2 * ATan(
			(Sin( (:latrad - Lag( :latrad, -1 )) / 2 ) ^ 2 + Cos( :latrad ) * Cos( Lag( :latrad, -1 ) ) * Sin( (:longrad - Lag( :longrad, -1 )) / 2 )
			 ^ 2) ^ 0.5,
			(1 - (Sin( (:latrad - Lag( :latrad, -1 )) / 2 ) ^ 2 + Cos( :latrad ) * Cos( Lag( :latrad, -1 ) ) * Sin(
				(:longrad - Lag( :longrad, -1 )) / 2
			) ^ 2)) ^ 0.5
		)
	)
);

dt &amp;lt;&amp;lt; New Column( "Bearing", Numeric, "Continuous", Format( "Latitude DMS", "PUNSGN", 15, 0 ),
	formula(
		brng = Mod(
			((ATan(
				Sin( Lag( :longrad, -1 ) - :longrad ) * Cos( Lag( :latrad, -1 ) ),
				Cos( :latrad ) * Sin( Lag( :latrad, -1 ) ) - Sin( :latrad ) * Cos( Lag( :latrad, -1 ) ) * Cos( Lag( :longrad, -1 ) - :longrad )
			)) * 180 / Pi()) + 360,
			360
		)
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 01 Sep 2019 01:06:19 GMT</pubDate>
    <dc:creator>ron_horne</dc:creator>
    <dc:date>2019-09-01T01:06:19Z</dc:date>
    <item>
      <title>Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19258#M17562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does anyone has idea how to calculate the distance between states in the US using either zip code or latitude and longitude?&lt;/P&gt;&lt;H4 style="padding-bottom: 0.5em; font-family: avenir-med, Arial, Helvetica, sans-serif; font-weight: normal; font-size: 2rem; color: #555555;"&gt;&lt;/H4&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jun 2016 13:05:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19258#M17562</guid>
      <dc:creator>jenkins_macedo</dc:creator>
      <dc:date>2016-06-27T13:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19259#M17563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;why not start here?&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/docs/DOC-7331" target="_blank"&gt;Add-In: Spatial Data Analysis&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and here&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/docs/DOC-6611" target="_blank"&gt;Distance Tool Add-In&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or just check my attached script for another option using a formula.&lt;/P&gt;&lt;P&gt;ron&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Oct 2016 13:28:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19259#M17563</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2016-10-28T13:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19260#M17564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great! Thanks &lt;A href="https://community.jmp.com/people/ron_horne"&gt;ron_horne&lt;/A&gt;​. I initially started using tjhe Geocoder-Map. But I also see that I had SDA. I also downloaded the Distance Tool. All pretty cool. What I am trying to do is pretty simple and straight forward. Using the location by City and State- (&lt;SPAN style="font-size: 13.3333px;"&gt;zip code/ geographic coordinates) &lt;/SPAN&gt;of our programs and the zip code of households in our databases. I am developing a simple file which shows programs that are under 50 miles of their residence compare to those that are 100 miles and proposed to the campaign team 2 to 3 programs that are either within an hour or two drive for a routine email marketing campaign based on their previous interests.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jun 2016 14:21:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19260#M17564</guid>
      <dc:creator>jenkins_macedo</dc:creator>
      <dc:date>2016-06-27T14:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19261#M17565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://kvoqx44227.lithium.com/people/ron_horne" target="_blank"&gt;ron_horne&lt;/A&gt;​ I tried using you "Distance to next" script to calculate the distance between two pairs of Lat and Long coordinates, but the script isn't working or maybe I am not doing something right. Attached is the first 20 rows of the table table. I would like to know the distance (in miles) between HH Lat and HH Long to PS Lat and PS long. I think once I can get the formula fitted to my data, it can be faster. I am not so sure how the Distance Tool would work here as I am wondering if I have to draw a line for each coordinate as that would take too much time as my table has over 2 million rows or can that be automated. I used the Mapping: JMP Geocoder to generate the coordinates below. How would you &lt;A href="https://kvoqx44227.lithium.com/people/ron_horne" target="_blank"&gt;ron_horne&lt;/A&gt;​ or some else customize these in Distance to next script posted previously? Any help would be appreciated. Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some information of the below variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Zip Code: is the matched household (HH) to the Progra Start Zip Code (PS).&lt;/P&gt;&lt;P&gt;Program Number: these numbers reflect programs we offer for which we would like to promote to those households within the same program-to-household zip code.&lt;/P&gt;&lt;P&gt;HH Latitude: Latitude associated with the Household zip code&lt;/P&gt;&lt;P&gt;HH Longitude: Longitude associated with the Household Zip Code&lt;/P&gt;&lt;P&gt;PS Latitude: Latitude associated with program start zip code. That is the location where the program started.&lt;/P&gt;&lt;P&gt;PS Longitude: Longitude associated with the program start zip code. That is the location where the program started.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="11935_Untitled.jpg" style="width: 573px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/3344i93AE5D4B497EDC96/image-size/medium?v=v2&amp;amp;px=400" role="button" title="11935_Untitled.jpg" alt="11935_Untitled.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2016 03:17:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19261#M17565</guid>
      <dc:creator>jenkins_macedo</dc:creator>
      <dc:date>2016-10-19T03:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19262#M17566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi &lt;A href="https://community.jmp.com/people/jenkins.macedo"&gt;jenkins.macedo&lt;/A&gt;​,&lt;/P&gt;&lt;P&gt;my original script calculated the distance between two consecutive rows in kilometers.&lt;/P&gt;&lt;P&gt;i have now amended it to produce the miles distance for each row.&lt;/P&gt;&lt;P&gt;try this on your table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Clear Globals&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;()&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Names Default To Here&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// reference the data table&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;dt &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;current data table&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;()&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// introduce the column with the distance to be updated in the dots table&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;dt &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;add multiple columns&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"Distance"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; after&lt;STRONG&gt;(&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;6&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; numeric &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// extract the longitude and the latitude values from the table - as radians&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;HHx &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Column&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; dt&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"HH Longitude"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;getValues&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Pi&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;()&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;/&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;180&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;HHy &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Column&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; dt&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"HH Latitude"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;getValues&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Pi&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;()&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;/&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;180&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;PSx &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Column&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; dt&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"PS Longitude"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;getValues&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Pi&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;()&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;/&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;180&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt; &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;PSy &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Column&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; dt&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple;"&gt;"PS Latitude"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;&amp;lt;&amp;lt;&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;getValues&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Pi&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;()&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;/&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;180&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// declare the calculation function in Miles&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;haversine &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Function&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;{&lt;/STRONG&gt;long1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; lat1&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; long2&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; lat2&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; R &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal;"&gt;6371&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;}&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;{&lt;/STRONG&gt;Default Local&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Sin&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;(&lt;/STRONG&gt;lat1 &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;-&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; lat2&lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;/&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;^&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;+&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Cos&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; lat1 &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Cos&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; lat2 &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;Sin&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;(&lt;/STRONG&gt;long1 &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;-&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; long2&lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;/&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;^&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;*&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;ATan&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; a &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;^&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;0.5&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;-&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; a&lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;^&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;0.5&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;(&lt;/STRONG&gt;R &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;*&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; c&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;*&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;0.6213712&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;// miles&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;)&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;wait&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; &lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal;"&gt;0.01&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;// run the function along the rows of the table&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;For&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; i &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; i &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: #0000dd;"&gt;N Row&lt;/SPAN&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; dt &lt;STRONG&gt;)&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;-&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10.0pt; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; i&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;++,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;:&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;distance&lt;STRONG&gt;[&lt;/STRONG&gt;i&lt;STRONG&gt;]&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; haversine&lt;STRONG&gt;(&lt;/STRONG&gt; HHx&lt;STRONG&gt;[&lt;/STRONG&gt;i&lt;STRONG&gt;]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; HHy&lt;STRONG&gt;[&lt;/STRONG&gt;i&lt;STRONG&gt;]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; PSx&lt;STRONG&gt;[&lt;/STRONG&gt;i&lt;STRONG&gt;]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; PSy&lt;STRONG&gt;[&lt;/STRONG&gt;i&lt;STRONG&gt;]&lt;/STRONG&gt; &lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: black; font-size: 10.0pt; font-family: 'Courier New';"&gt;)&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: navy;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jun 2016 20:02:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19262#M17566</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2016-06-30T20:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19263#M17567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A href="https://community.jmp.com/people/ron_horne"&gt;ron_horne&lt;/A&gt;​. I will let you know the outcome once I tried it. But I think it looks great! Big tx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jul 2016 11:51:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/19263#M17567</guid>
      <dc:creator>jenkins_macedo</dc:creator>
      <dc:date>2016-07-01T11:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/43618#M25239</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.jmp.com/people/ron_horne" target="_blank"&gt;ron_horne&lt;/A&gt;&amp;nbsp;and I hope you are doing well. I know this has taken some time since we last chatted on this thread. The project was put on hold and it is now up and running and in about few weeks, the resulting table will be deployed in production by our campaign team.&lt;/P&gt;&lt;P&gt;I did apply the script and it worked perfectly as expected!! Great job!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you know the script calculates the distance between pairs of (HH Lat. and HH Long.) to (PS Lat and PS Long.), which is what was originally what the project was designed to capture. I have used the resulting distance to calculate the time that it will take for each household to attend one of our program that is 1, 3, or 5 hours away from their homes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, the issue is that I would like to script to calculate the distance between each pair of Lat. and Long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;In the table below, I have computed the distance and time between row 1 pairs of Lat. &amp;amp; Long. Which is perfect!! that will do for all 20 rows giving 20 unique distances between household location to the destination of the program.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, in row 1 the program # 15896 with PS Lat. 56.47 N &amp;amp; PS Long. 132.38 S is certain distance away from the Household whose HH Lat. &amp;amp; HH Long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since we want to know the distance of each household from each program #, how can I calculate, such that, JMP captures the distance between each household Lat and Long acrosss each Program Lat and Long and not just the first program? In this table, I have 20 rows, using what I have described we&amp;nbsp;should have 400 difference distance calculation instead of just 20. Do you know a way to go around this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My original HH Data Table has 156,737 Unique households records with their respective HH Lat. &amp;amp; HH Long. The Household file has 15,655 unique HH Lat. &amp;amp; HH Long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Program Data Table with 2,747 Unique Program #s with 329 unique PS Lat. &amp;amp; PS Long. I want to calculate the distance from each unique household Lat. &amp;amp; Long&amp;nbsp;to each unique Program Lat. &amp;amp; Long., such that, the distance is calculated across each program. That will be 15,655 *329 and the resulting table or the total distance should be about 5,150,495 records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.jpg" style="width: 576px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/7299i296776DEC74894D4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.jpg" alt="Untitled.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 21:05:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/43618#M25239</guid>
      <dc:creator>jenkins_macedo</dc:creator>
      <dc:date>2017-08-24T21:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/224020#M44527</link>
      <description>&lt;P&gt;Another thank you to ron_horne!&amp;nbsp; Just a couple questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just want to confirm the output is statute miles, correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, do you have a script for bearing between two coordinates?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 19:28:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/224020#M44527</guid>
      <dc:creator>mjvincent87</dc:creator>
      <dc:date>2019-08-28T19:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/224035#M44530</link>
      <description>&lt;P&gt;Amazing collection of formulas:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.movable-type.co.uk/scripts/latlong.html" target="_blank" rel="noopener"&gt;http://www.movable-type.co.uk/scripts/latlong.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 01:01:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/224035#M44530</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-08-29T01:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/224295#M44579</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13069"&gt;@mjvincent87&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;have a look at this script and let me know if it is the direction you are thinking of:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
Clear Globals();
Names Default To Here( 1 );

// open data file (dots) - this includes the observation we want to update
dt = Open( "$SAMPLE_DATA/Hurricanes.jmp" );

// introduce the column with the distance to be updated in the dots table
dots &amp;lt;&amp;lt; New column ( "Distance", Numeric );

// introduce the column with the distance to be updated in the dots table
Dots &amp;lt;&amp;lt; New Column("Bearing", Numeric, "Continuous", Format("Latitude DMS", "PUNSGN", 15, 0));

// extract the longitude and the latitude values from the table - as radians
x = (Column( dots, "Longitude" ) &amp;lt;&amp;lt; getValues) * Pi() / 180 ; 
y = (Column( dots, "Latitude" ) &amp;lt;&amp;lt; getValues) * Pi() / 180 ; 


// declare the distance calculation function in KM based on world radius of 6371 KM.
// For statute miles multiply final distance d by 0.621371.
// For nautical miles multiply final distance d by 0.539957
haversine = Function( {long1, lat1, long2, lat2, R = 6371.009},
	{Default Local},
	a = Sin( (lat1 - lat2) / 2 ) ^ 2 + Cos( lat1 ) * Cos( lat2 ) * Sin( (long1 - long2) / 2 ) ^ 2;
	c = 2 * ATan( a ^ 0.5, (1 - a) ^ 0.5 );
	d = R * c //  *0.621371 For statute miles;
);

wait (0.01);

// run the function along the rows of the table
For( i = 1, i &amp;lt;= N Row( dots ) - 1, i++,
	dots:distance[i] = haversine( x[i], y[i], x[i + 1], y[i + 1] )
);


// Declare the Bearing calculation function
Bearing = function ({long1, lat1, long2, lat2 },
	{Default Local},
	abc = sin (long2 - long1) * cos (lat2);
	def = cos (lat1) * sin (lat2) - sin (lat1) *cos (lat2) * cos (long2 - long1) ;
	brng = mod (( (atan ( abc, def )) * 180 / pi() ) + 360 , 360)  ;

);
wait (0.01);

// run the Bearing function along the rows of the table
For( i = 1, i &amp;lt;= N Row( dots ) - 1, i++,
	dots:Bearing[i] = Bearing( x[i], y[i], x[i + 1], y[i + 1] )
);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;ron&lt;/P&gt;</description>
      <pubDate>Sun, 01 Sep 2019 00:30:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/224295#M44579</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2019-09-01T00:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/224296#M44580</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13069"&gt;@mjvincent87&lt;/a&gt; and &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1025"&gt;@jenkins_macedo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;another way of doing this is with column formula in a data table. try the following script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Clear Globals();
Names Default To Here( 1 );

// Open data file
dt = Open( "$SAMPLE_DATA/Cities.jmp" );

// add column for distance
dt &amp;lt;&amp;lt; New Column( "latrad", formula( :Latitude * (Pi() / 180) ) );
dt &amp;lt;&amp;lt; New Column( "longrad", formula( :Longitude * (Pi() / 180) ) );

dt &amp;lt;&amp;lt; New Column( "Distance", Numeric,
	formula(
		6371.00 * 2 * ATan(
			(Sin( (:latrad - Lag( :latrad, -1 )) / 2 ) ^ 2 + Cos( :latrad ) * Cos( Lag( :latrad, -1 ) ) * Sin( (:longrad - Lag( :longrad, -1 )) / 2 )
			 ^ 2) ^ 0.5,
			(1 - (Sin( (:latrad - Lag( :latrad, -1 )) / 2 ) ^ 2 + Cos( :latrad ) * Cos( Lag( :latrad, -1 ) ) * Sin(
				(:longrad - Lag( :longrad, -1 )) / 2
			) ^ 2)) ^ 0.5
		)
	)
);

dt &amp;lt;&amp;lt; New Column( "Bearing", Numeric, "Continuous", Format( "Latitude DMS", "PUNSGN", 15, 0 ),
	formula(
		brng = Mod(
			((ATan(
				Sin( Lag( :longrad, -1 ) - :longrad ) * Cos( Lag( :latrad, -1 ) ),
				Cos( :latrad ) * Sin( Lag( :latrad, -1 ) ) - Sin( :latrad ) * Cos( Lag( :latrad, -1 ) ) * Cos( Lag( :longrad, -1 ) - :longrad )
			)) * 180 / Pi()) + 360,
			360
		)
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Sep 2019 01:06:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/224296#M44580</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2019-09-01T01:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/260936#M51088</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/958"&gt;@ron_horne&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;I tried to use this script for calculating distances, but I had an error message when I tried. Since the script is from 2016, maybe some things have changed?&lt;/P&gt;&lt;P&gt;An update of the script will be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2020 10:12:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/260936#M51088</guid>
      <dc:creator>MerGrung</dc:creator>
      <dc:date>2020-04-24T10:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/260956#M51090</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/18637"&gt;@MerGrung&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;if you can post a sample of the data and the script you are using we can fix it for you.&lt;/P&gt;
&lt;P&gt;otherwise, it is hard to tell what is the source of the error.&lt;/P&gt;
&lt;P&gt;one thing that most likely has changed since 2016 is the reference to the sample data. in my original script it had a reference to JMP11 x86. if you are using a later version it will for sure give you an error message.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2020 11:36:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/260956#M51090</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2020-04-24T11:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Distance Calculation using Latitude and Longitude</title>
      <link>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/262103#M51298</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/958"&gt;@ron_horne&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thanks for your quick reply!&lt;/P&gt;&lt;P&gt;I worked a bit more with the script, and discovered that the fault was on my side. I managed to calculate the distances without problem.&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 21:24:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Distance-Calculation-using-Latitude-and-Longitude/m-p/262103#M51298</guid>
      <dc:creator>MerGrung</dc:creator>
      <dc:date>2020-04-28T21:24:11Z</dc:date>
    </item>
  </channel>
</rss>

