Getting values using coordinates indexes

I have a very simple question,
I have 3 matrices extracted from a netcdf file, latitude, longitude, and data values (Z). I would like to know the Z values corresponding to specific latitude and longitude points. How can I do this?
Thanks

1 件のコメント

SnovG
SnovG 2015 年 6 月 8 日
These are thress matrices with the same size, 2630x1083 double, it is actually remote sensing data in netcdf format. I want to get the values corresponding to the coordinates. thanks

サインインしてコメントする。

回答 (1 件)

Chad Greene
Chad Greene 2015 年 6 月 8 日

1 投票

You can do this a few ways. If you know the exact lat and lon you're interested in, say (30N,120E), it's simply
Z(lat==30 & lon==120)
Alternatively, you can use interp2.

4 件のコメント

SnovG
SnovG 2015 年 6 月 8 日
Thank you Chad, that works, but what if I know the approximate coordinates and I want to find the closest point to those coordinates? Thanks
Chad Greene
Chad Greene 2015 年 6 月 8 日
Depending on what you're trying to do, you could round your lat/lon of interest to the nearest gridded lat/lon value, or you could use interp2 with the 'nearest' option, or you could use near2, which simply finds the nearest row and column index.
SnovG
SnovG 2015 年 6 月 10 日
thank you!
K E
K E 2015 年 8 月 5 日
Once you know the index to the lat/lon point you want, you can extract just the value there using ncread. In other words you don't have to pull the whole matrix into Matlab.

サインインしてコメントする。

質問済み:

2015 年 6 月 8 日

コメント済み:

K E
2015 年 8 月 5 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by