Find nearest grid cell between two 2D matrixes of different resolution
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Melissa
le 15 Mai 2015
Commenté : Walter Roberson
le 15 Mai 2015
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
0 commentaires
Réponse acceptée
Walter Roberson
le 15 Mai 2015
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 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!