Distance Matrix Calculate: Haversine formula

Hello,

I wanted  to calculate distances between geographic locations given as (latitude, longitude) pairs and I found a solution using Java Distance (attached example workflow). If you want result in miles, change the Earth to 3959 mi (6371 km).

If you are intrested in that topic (or different formulas) visit:
- http://www.movable-type.co.uk/scripts/latlong.html
- http://rosettacode.org/wiki/Haversine_formula
- https://stackoverflow.com/questions/120283/how-can-i-measure-distance-and-create-a-bounding-box-based-on-two-latitudelongi

Best,
Robert

2 Likes

-- Philipp

I know, I wanted to get another solution (more flexible).
The result in this case is the same.

Robert

Hi rchar01,
Thanks for providing this example. I have a question that maybe someone can help me with… I am trying to run this file but only have the distance calculate by region.
For example, if in my file I had an additional column, “region”, I would want to calculate points in region A only with other points in region A, points in region B only with other points in region B, etc. The only way I can think to do this is to split regions into their own separate input files, but that method is quite cumbersome.
I’ve tried using row filter and group nodes but haven’t been able to successfully pull this off.

Thanks again!
-Snowy

Could you give an example of the input data and the expected result (e.g. in csv file)?

Hi rchar01,
This is what I was hoping to achieve…
Input:

Output:

I ended up following my own suggestion but instead of having separate input files, I simply added a filter node. So the final product looks like this:

And the detail view:

The “constant value” node was used to reapply the region information.

I think I managed to solve this problem, I attached a workflow.