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

3 次查看(过去 30 天)
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.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by