Sponsored Content
Top Forums Shell Programming and Scripting Calculate average, azimut and distance Post 302968293 by jiam912 on Monday 7th of March 2016 03:32:09 PM
Old 03-07-2016
Calculate average, azimut and distance

Gents,

Please i will to get the distance and azimut from 2 coordinates:

Usig excel formula i get the correct values, but i will like to do it using awk.

Example

Code:
A         35089.0 50345.016 9 75   1   2101774 77 70 79 483911.6 2380106.9 137.4     1 1 6 1
A         35089.0 50345.01620 75   1   2111874 80 71 78 483911.7 2380118.1 137.4     1 1 6 1

formula to apply
Code:
average x = average(483911.6, 483911.7 ) = 483911.7
average y = average(2380106.9, 2380118.1) = 2380112.5
average z = average(137.4, 137.4) = 137.4
Azimut =IF(483911.6=483911.7),90,(ABS(DEGREES(ATAN((2380106.9-2380118.1)/(483911.6-483911.7))))))
Distance =SQRT((483911.6-483911.7)^2+(2380106.9-2380118.1)^2)

Code:
A         35089.0 50345.016 9 75   1   2101774 77 70 79 483911.7 2380112.5 137.4     1 1 6 1 89.5  11.2

input
Code:
A         35089.0 50345.016 9 75   1   2101774 77 70 79 483911.6 2380106.9 137.4     1 1 6 1
A         35089.0 50345.01620 75   1   2111874 80 71 78 483911.7 2380118.1 137.4     1 1 6 1
A         35089.0 50357.016 9 75   1   2111674 77 70 79 484062.3 2380118.1 136.5     2 1 6 1
A         35089.0 50357.01620 75   1   3111974 78 72 79 484061.7 2380106.8 136.4     2 1 6 1
A         35089.0 50369.016 9 75   1   2 91574 77 69 81 484212.8 2380105.6 136.7     3 1 6 1
A         35089.0 50369.01620 75   1   2101474 79 70 79 484212.9 2380116.8 136.2     3 1 6 1
A         35089.0 50381.016 9 75   1   2 91574 77 71 78 484361.9 2380117.9 134.9     4 1 6 1
A         35089.0 50381.01620 75   1   2101374 79 73 78 484361.7 2380106.6 135.4     4 1 6 1

output desired
Code:
A         35089.0 50345.016 9 75   1   2101774 77 70 79 483911.7 2380112.5 137.4     1 1 6 1 89.5  11.2
A         35089.0 50357.016 9 75   1   2111674 77 70 79 484062.8 2380112.5 136.5     2 1 6 1 87.0  11.3
A         35089.0 50369.016 9 75   1   2 91574 77 69 81 484212.9 2380111.2 136.5     3 1 6 1 89.5  11.2
A         35089.0 50381.016 9 75   1   2 91574 77 71 78 484361.8 2380112.3 135.2     4 1 6 1 89.0  11.3

Hope you can help me
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

calculate average of column 2

Hi I have fakebook.csv as following: F1(current date) F2(popularity) F3(name of book) F4(release date of book) 2006-06-21,6860,"Harry Potter",2006-12-31 2006-06-22,,"Harry Potter",2006-12-31 2006-06-23,7120,"Harry Potter",2006-12-31 2006-06-24,,"Harry Potter",2006-12-31... (0 Replies)
Discussion started by: onthetopo
0 Replies

2. UNIX for Dummies Questions & Answers

Use awk to calculate average of column 3

Suppose I have 500 files in a directory and I need to Use awk to calculate average of column 3 for each of the file, how would I do that? (6 Replies)
Discussion started by: grossgermany
6 Replies

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

4. Programming

calculate average

I have a file which is 2 3 4 5 6 6 so i am writing program in C to calculate mean.. #include<stdio.h> #include<string.h> #include <math.h> double CALL mean(int n , double x) main (int argc, char **argv) { char Buf,SEQ; int i; double result = 0; FILE *fp; (3 Replies)
Discussion started by: cdfd123
3 Replies

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

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

7. Shell Programming and Scripting

AWK novice - calculate the average

Hi, I have the following data in a file for example: P1 XXXXXXX.1 YYYYYYY.1 ZZZ.1 P1 XXXXXXX.2 YYYYYYY.2 ZZZ.2 P1 XXXXXXX.3 YYYYYYY.3 ZZZ.3 P1 XXXXXXX.4 YYYYYYY.4 ZZZ.4 P1 XXXXXXX.5 YYYYYYY.5 ZZZ.5 P1 XXXXXXX.6 YYYYYYY.6 ZZZ.6 P1 XXXXXXX.7 YYYYYYY.7 ZZZ.7 P1 XXXXXXX.8 YYYYYYY.8 ZZZ.8 P2... (6 Replies)
Discussion started by: alex2005
6 Replies

8. Shell Programming and Scripting

Calculate Average AWK

I want to calculate the average line by line of some files with several lines on them, the files are identical, just want to average the 3rd columns of those files.:wall: Example file: File 1 001 0.046 0.667267 001 0.047 0.672028 001 0.048 0.656025 001 0.049 ... (2 Replies)
Discussion started by: AriasFco
2 Replies

9. Shell Programming and Scripting

Calculate average for repeated ID within a data

I have an awk script that gives the following output: Average end-to-end transmission delay 2.7 to 5.7 is 0.635392 seconds Average end-to-end transmission delay 2.1 to 5.1 is 0.66272 seconds Average end-to-end transmission delay 2.1 to 5.1 is 0.691712 seconds Average end-to-end transmission... (4 Replies)
Discussion started by: ENG_MOHD
4 Replies

10. Shell Programming and Scripting

Calculate the average per block.

My old school way is a one liner. And will search for average from SAR, to get the data receive rate. But, I dont think it is practical or accurate,. Because it calculates to off peak hours. I am planning to change it. My cron runs every 30 mins. When my cron runs, and my time is 14:47pm,, it will... (1 Reply)
Discussion started by: invinzin21
1 Replies
All times are GMT -4. The time now is 12:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy