Find nearest grid cell between two 2D matrixes of different resolution

2 ビュー (過去 30 日間)
Melissa
Melissa 2015 年 5 月 15 日
コメント済み: Walter Roberson 2015 年 5 月 15 日
Hello,
I have two matrices I would like to compare.
A is 192(lon) x 288(lat) B is 360(lat) x 720(lon)
How can I regrid B so that its resolution is the same as A?
I would like to know how to do this both by finding the nearest B lat&lon&values for A, and also by decimating B to the coarser resolution of A
Thank you,
Melissa

採用された回答

Walter Roberson
Walter Roberson 2015 年 5 月 15 日
Assuming that they are regular grids with known latitude and longitude vectors, Along, Alat, Blong, Blat, then the approximation that neglects curvature of the Earth would be
[X, Y] = meshgrid(Blat, Blong);
[Xq, Yq] = meshgrid(Alat, Along);
Bapprox = interp2(X, Y, B, Xq, Yq);
The interp2() would need the longitude vectors phase-unwrapped if they cross 180 to -180:
degrad = pi./180;
unwrappedBlong = unwrap(Blong .* degrad) ./ degrad;
If you do need to take the curvature of the Earth into account, then possibly mapprofile might turn out to be usable for you -- I am too tired at the moment to figure out what a refmatrix is.
If mapprofile is not suitable then perhaps someone has already built a routine. If not then intrplon might help.
  2 件のコメント
Melissa
Melissa 2015 年 5 月 15 日
thanks! What do I do if it says,
Error
The grid was created from grid vectors that were not strictly monotonic increasing.
Walter Roberson
Walter Roberson 2015 年 5 月 15 日
That's when you have to do the unwrapping like I showed.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by