Sponsored Content
Top Forums Shell Programming and Scripting Lat/Long Distance Calculation Post 302113988 by ghostdog74 on Wednesday 11th of April 2007 11:15:37 PM
Old 04-12-2007
If you have Python, here's an alternative:
Code:
from math import sin , cos, acos
A = 34.16597 
B = -84.33244
C = 34.2344 
D = -84.29189
result = ( sin(A) * sin(C) )+  ( cos(A) * cos(C) * cos(B-D) )
if A == C or B == D:
    print "The distance is zero"
elif result > 1:
    print "The distance is " , 3963.1 * acos(1) 
else:
    print "The distance is " , acos(result)

output:
Code:
# ./test.py
The distance is  0.0782622048633

 

9 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

program to calculate distance between 5 atoms

Hello, I am a beginner with perl. I have a perl program to calculate the distance between 5 atoms or more. i have an array which looks like this: 6.324 32.707 50.379 5.197 32.618 46.826 4.020 36.132 46.259 7.131 38.210 45.919 6.719 38.935 42.270 2.986 39.221 ... (1 Reply)
Discussion started by: annie_singh
1 Replies

3. 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

4. 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

5. 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

6. UNIX for Dummies Questions & Answers

How to make a distance matrix

Hi, I'm trying to generate a distance matrix between sample pairs for use in a tree-drawing program (example below). The example below demonstrates what I'd like to get out of the data - essentially, to calculate the proportion of positions where two samples differ. Any help much appreciated!... (1 Reply)
Discussion started by: auburn
1 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 distance between long and lat in bash

Does anyone know of any script or packages that allow the calculation of the geographical distance between two points of lat/long from within a bash shell? I have been searching the web for the past few days and none of the options seem compatible with bash variables... (eg. geodist) Many... (3 Replies)
Discussion started by: lily-anne
3 Replies

9. Shell Programming and Scripting

Edit distance using perl or awk

Dear all, I am working on a large Sindhi lexicon which I hope to complete by 2017 and place in open source. The database is in Arabic script in two columns delimited by an equal to sign. Column 1 contains a word or words without the short vowel and also some extraneous information which is... (0 Replies)
Discussion started by: gimley
0 Replies
Tk_GetPixelsFromObj(3)					       Tk Library Procedures					    Tk_GetPixelsFromObj(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_GetPixelsFromObj, Tk_GetPixels, Tk_GetMMFromObj, Tk_GetScreenMM - translate between strings and screen units SYNOPSIS
#include <tk.h> int Tk_GetPixelsFromObj(interp, tkwin, objPtr, intPtr) int Tk_GetPixels(interp, tkwin, string, intPtr) int Tk_GetMMFromObj(interp, tkwin, objPtr, doublePtr) int Tk_GetScreenMM(interp, tkwin, string, doublePtr) ARGUMENTS
Tcl_Interp *interp (in) Interpreter to use for error reporting. Tk_Window tkwin (in) Window whose screen geometry determines the conversion between absolute units and pixels. Tcl_Obj *objPtr (in/out) String value specifies a distance on the screen; internal rep will be modified to cache converted dis- tance. const char *string (in) Same as objPtr except specification of distance is passed as a string. int *intPtr (out) Pointer to location in which to store converted distance in pixels. double *doublePtr (out) Pointer to location in which to store converted distance in millimeters. _________________________________________________________________ DESCRIPTION
These procedures take as argument a specification of distance on the screen (objPtr or string) and compute the corresponding distance either in integer pixels or floating-point millimeters. In either case, objPtr or string specifies a screen distance as a floating-point number followed by one of the following characters that indicates units: <none> The number specifies a distance in pixels. c The number specifies a distance in centimeters on the screen. i The number specifies a distance in inches on the screen. m The number specifies a distance in millimeters on the screen. p The number specifies a distance in printer's points (1/72 inch) on the screen. Tk_GetPixelsFromObj converts the value of objPtr to the nearest even number of pixels and stores that value at *intPtr. It returns TCL_OK under normal circumstances. If an error occurs (e.g. objPtr contains a number followed by a character that is not one of the ones above) then TCL_ERROR is returned and an error message is left in interp's result if interp is not NULL. Tk_GetPixelsFromObj caches information about the return value in objPtr, which speeds up future calls to Tk_GetPixelsFromObj with the same objPtr. Tk_GetPixels is identical to Tk_GetPixelsFromObj except that the screen distance is specified with a string instead of an object. This prevents Tk_GetPixels from caching the return value, so Tk_GetAnchor is less efficient than Tk_GetPixelsFromObj. Tk_GetMMFromObj and Tk_GetScreenMM are similar to Tk_GetPixelsFromObj and Tk_GetPixels (respectively) except that they convert the screen distance to millimeters and store a double-precision floating-point result at *doublePtr. KEYWORDS
centimeters, convert, inches, millimeters, pixels, points, screen units Tk 8.1 Tk_GetPixelsFromObj(3)
All times are GMT -4. The time now is 09:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy