locating the closest values? [message #84680] |
Tue, 26 June 2012 14:07 |
anil
Messages: 34 Registered: August 2009
|
Member |
|
|
Hi,
I have 2 ascii files/datasets. 1st file contains latitude and
longitude pairs(2 columns) in each line. 2nd file contains also
latitude longitude and also a 3rd column, depth. What i want to do ,
is to read each line from file 1(desiredlon and lat), and then find
the closest latitude and longitudes and the corresponding depth in
file 2.
I did something like this:
difference1=abs(lon-desiredlon)
a1=min(difference1,index1)
difference2=abs(lon-desiredlat)
a2=min(difference2,index2)
when i check, lon(index1) and lat(index2) gives correct results. but
i could not read the 3rd column/depth using these indexes. Is there
any other way to do this?
My 2nd file is ~35000 lines. For each longitude there are many
matching longitudes in the 2nd file, it is the same for latitude. But
there is only one single point for each pair of coordinates. How can i
match them and find the depth in that row?
|
|
|