Sponsored Content
Top Forums Shell Programming and Scripting Geographical distance between long and lat in bash Post 302914058 by Perderabo on Thursday 21st of August 2014 02:50:22 PM
Old 08-21-2014
The formula to compute the distance between a pair of latitude-longitude coordinates is actually rather complex. A simplified version is on this page.

**edit**
Actually, that doesn't look right. Earth's radius is more like 4000 miles. Your milage may vary. Smilie

** another edit **
I see what's happening.
Earth radius is:
3443 statute miles
3963 nautical miles
Make sure you don't confuse the two. Nautical miles would be the unit most likely used in a calculation like this.

Last edited by Perderabo; 08-21-2014 at 04:10 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Lat/Long Distance Calculation

I amtrying to write a script that would compute the distance between an "x" number of points. This is what I have come up with so far and it is not working. Can anyone modify it to make it work? A=34.16597 B=-84.33244 C=34.2344 D=-84.29189 test "$A" -eq "$C" -o "$B" -eq "$D" then echo... (3 Replies)
Discussion started by: Ernst
3 Replies

2. UNIX for Dummies Questions & Answers

Long Distance UNIX (Solaris) Cloning ?

Need some advice and guidance for this UNIX beginner. Due to downsizing I have inherited the SysAdmin duties..(sigh). Please excuse and forgive me if I use the wrong terms below.... Situation: We have UNIX ( Solaris 7/8/9( it varies) on Sun Ultra 10's) servers located at several global... (1 Reply)
Discussion started by: HikerLT
1 Replies

3. Shell Programming and Scripting

Find the geographical location within a shell script

Hi, I need a shell script that when run should be able to find the geographical location of the system. can anyone help me with this? Thanks, Sundeep (1 Reply)
Discussion started by: eamani_sun
1 Replies

4. Programming

Converting distance list to distance matrix in R

Hi power user, I have this type of data (distance list): file1 A B 10 B C 20 C D 50I want output like this # A B C D A 0 10 30 80 B 10 0 20 70 C 30 20 0 50 D 80 70 50 0 Which is a distance matrix I have tried... (0 Replies)
Discussion started by: anjas
0 Replies

5. Shell Programming and Scripting

Calculate distance and azimuth

Hi all, I have a data file like this lat lon lat lon 12.000 25.125 14.235 25.012 14.200 81.000 25.584 25.014 45.023 25.365 25.152 35.222 I want to calculate distance and azimuth between this points eg:- 12.000,25.125 and 14.235,25.012 I want to use awk programming... (3 Replies)
Discussion started by: chamara
3 Replies

6. Shell Programming and Scripting

Calculating distance between two LAT long coordinates

hi, i have a pair of latitude and longitude and i want to calculate the distance between these two points. In vbscript i achieved in the following way...Now i want to implement this in unix shell scripting.... <% Dim lat1, lon1, lat2, lon2 const pi = 3.14159265358979323846 ... (8 Replies)
Discussion started by: aemunathan
8 Replies

7. Shell Programming and Scripting

finding distance between numbers

Hi, I have a file as ABC 1634230,1634284,1634349,1634468 1634272,1634301,1634356,1634534 What I want is to find distance between the numbers.. column 1 is the gene name and column 2 are starts and column 3 are their respective stops for the starts. So what I want is column 3 which has +1... (2 Replies)
Discussion started by: Diya123
2 Replies

8. Shell Programming and Scripting

Geographical location details of a server

Is there a way to find geographical location details of a server in shell scripting ? Say, which region server is located at etc. (5 Replies)
Discussion started by: blp_18
5 Replies

9. UNIX for Dummies Questions & Answers

Bash does not wrap long lines correctly

Ksh is my default shell, but I want use the bash shell since its convenient to me. When I type a long command line in a terminal, it does not wrap to the next line when I reach the end of the line and it wraps onto the same line, overwriting my prompt and the rest of what I typed. $... (5 Replies)
Discussion started by: senthil.ak
5 Replies
Geo::Distance::XS(3pm)					User Contributed Perl Documentation				    Geo::Distance::XS(3pm)

NAME
Geo::Distance::XS - speed up Geo::Distance SYNOPSIS
use Geo::Distance::XS; my $geo = Geo::Distance->new; my $distance = $geo->distance(mile => $lon1, $lat1 => $lon2, $lat2); DESCRIPTION
The "Geo::Distance::XS" module provides faster C implementations of the distance calculations found in "Geo::Distance". See the documentation for that module for usage. NOTE: As of version 0.13, Geo::Distance automatically uses this module if it is installed. FORMULAS
In addition to the formulas offered in "Geo::Distance", this module implements the additional formulas: alt: Andoyer-Lambert-Thomas Formula This is faster than the Vincenty formula, but trades a bit of accuracy. PERFORMANCE
This distribution contains a benchmarking script which compares "Geo::Distance::XS" with "Geo::Distance" and "GIS::Distance::Fast". These are the results on a MacBook 2GHz with Perl 5.14.2: ---- [ Formula: hsin ] ------------------------------------ perl - distance from LA to NY: 2443.08796228363 miles xs - distance from LA to NY: 2443.08796228363 miles gis_fast - distance from LA to NY: 2443.08796228363 miles Rate gis_fast perl xs gis_fast 24802/s -- -70% -98% perl 81919/s 230% -- -92% xs 1003704/s 3947% 1125% -- ---- [ Formula: tv ] ------------------------------------ perl - distance from LA to NY: 2448.24135235512 miles xs - distance from LA to NY: 2448.2413523656 miles gis_fast - distance from LA to NY: 2448.24135235512 miles Rate perl gis_fast xs perl 18101/s -- -19% -95% gis_fast 22330/s 23% -- -94% xs 345717/s 1810% 1448% -- ---- [ Formula: polar ] ------------------------------------ perl - distance from LA to NY: 2766.02509696782 miles xs - distance from LA to NY: 2766.02509696782 miles gis_fast - distance from LA to NY: 2766.02509696782 miles Rate gis_fast perl xs gis_fast 19200/s -- -78% -98% perl 87682/s 357% -- -93% xs 1214700/s 6227% 1285% -- ---- [ Formula: cos ] ------------------------------------ perl - distance from LA to NY: 2443.08796228363 miles xs - distance from LA to NY: 2443.08796228363 miles gis_fast - distance from LA to NY: 2443.08796228363 miles Rate gis_fast perl xs gis_fast 24435/s -- -69% -98% perl 78913/s 223% -- -93% xs 1147836/s 4597% 1355% -- ---- [ Formula: gcd ] ------------------------------------ perl - distance from LA to NY: 2443.08796228363 miles xs - distance from LA to NY: 2443.08796228363 miles gis_fast - distance from LA to NY: 2443.08796228363 miles Rate gis_fast perl xs gis_fast 18270/s -- -75% -98% perl 74472/s 308% -- -93% xs 1102769/s 5936% 1381% -- ---- [ Formula: mt ] ------------------------------------ perl - distance from LA to NY: 2443.08796228363 miles xs - distance from LA to NY: 2443.08796228363 miles gis_fast - distance from LA to NY: 2443.08796228363 miles Rate gis_fast perl xs gis_fast 17935/s -- -75% -98% perl 71739/s 300% -- -94% xs 1135525/s 6231% 1483% -- This distribution contains another benchmarking script which compares only the XS formulas over several different coordinates: Rate tv hsin alt cos mt gcd polar tv 16906/s -- -90% -90% -91% -91% -91% -92% hsin 165414/s 878% -- -4% -8% -10% -13% -17% alt 172032/s 918% 4% -- -5% -7% -9% -14% cos 180326/s 967% 9% 5% -- -2% -5% -10% mt 184357/s 991% 11% 7% 2% -- -3% -8% gcd 189253/s 1019% 14% 10% 5% 3% -- -6% polar 200386/s 1085% 21% 16% 11% 9% 6% -- Calculated length for short distance: alt : 40.3740136064528 miles cos : 40.3095459813536 miles gcd : 40.3095459813294 miles hsin : 40.3095459813294 miles mt : 40.3095459813536 miles polar: 46.7467797109043 miles tv : 40.3740136384531 miles Calculated length for long distance: alt : 2448.24135691376 miles cos : 2443.08796228363 miles gcd : 2443.08796228363 miles hsin : 2443.08796228363 miles mt : 2443.08796228363 miles polar: 2766.02509696782 miles tv : 2448.2413523656 miles Calculated length for nearly antipodes: alt : 12340.6455133245 miles cos : 12340.327635068 miles gcd : 12340.327635068 miles hsin : 12340.327635068 miles mt : 12340.327635068 miles polar: 12368.4764642469 miles tv : 12340.7483034002 miles Calculated length for antipodes: alt : 12429.86673988 miles cos : 219.005548031861 miles gcd : 12438.0476860875 miles hsin : 12438.0475680956 miles mt : 219.005548031861 miles polar: 12438.0476860875 miles tv : 12370.1885059814 miles Calculated length for polar antipodes: alt : 12429.86673988 miles cos : 12438.0476860875 miles gcd : 12438.0476860875 miles hsin : 12438.0476860875 miles mt : 12438.0476860875 miles polar: 12438.0476860875 miles tv : 12429.8667398787 miles SEE ALSO
Geo::Distance http://blogs.esri.com/esri/apl/2010/09/28/fast-times-at-geodesic-high/ <http://blogs.esri.com/esri/apl/2010/09/28/fast-times-at-geodesic- high/> REQUESTS AND BUGS
Please report any bugs or feature requests to http://rt.cpan.org/Public/Bug/Report.html?Queue=Geo-Distance-XS <http://rt.cpan.org/Public/Bug/Report.html?Queue=Geo-Distance-XS>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT
You can find documentation for this module with the perldoc command. perldoc Geo::Distance::XS You can also look for information at: o GitHub Source Repository http://github.com/gray/geo-distance-xs <http://github.com/gray/geo-distance-xs> o AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/Geo-Distance-XS <http://annocpan.org/dist/Geo-Distance-XS> o CPAN Ratings http://cpanratings.perl.org/d/Geo-Distance-XS <http://cpanratings.perl.org/d/Geo-Distance-XS> o RT: CPAN's request tracker http://rt.cpan.org/Public/Dist/Display.html?Name=Geo-Distance-XS <http://rt.cpan.org/Public/Dist/Display.html?Name=Geo-Distance-XS> o Search CPAN http://search.cpan.org/dist/Geo-Distance-XS/ <http://search.cpan.org/dist/Geo-Distance-XS/> COPYRIGHT AND LICENSE
Copyright (C) 2009-2012 gray <gray at cpan.org>, all rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHOR
gray, <gray at cpan.org> perl v5.14.2 2012-04-14 Geo::Distance::XS(3pm)
All times are GMT -4. The time now is 07:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy