Regridding Latitude/Longitude File

1 visualización (últimos 30 días)
YOlivo
YOlivo el 28 de Jun. de 2018
Respondida: Raag el 17 de Feb. de 2025
I am looking to regrid a lat/lon grid file similar to the picture below. Specifically, I am trying to upscale from a 2km domain to a 10km domain. Any suggestions help.

Respuestas (1)

Raag
Raag el 17 de Feb. de 2025
Hi YOlivo,
The issue in regridding your data from a 2km to 10km domain arises because a 10km grid cell corresponds to a 5x5 block of 2km cells, You will need to aggregate those blocks to obtain your new coarser grid.
Here are the steps to follow:
  • Check that your original 2km data dimensions are multiple of 5
[nLat_2km, nLon_2km] = size(Z_2km);
if mod(nLat_2km, 5) ~= 0 || mod(nLon_2km, 5) ~= 0
error('Dimensions are not multiples of 5. Cannot block-average cleanly.');
end
  • Reshape your data into bock of 5x5
nDivLat = nLat_2km / 5;
nDivLon = nLon_2km / 5;
Z_reshaped = reshape(Z_2km, 5, nDivLat, 5, nDivLon);
  • Compute the average over each 5x5 block
Z_10km = squeeze(mean(mean(Z_reshaped, 1), 3));
  • Construct the new latitude/longitude arrays
%If 'lat_2km' and 'lon_2km' are your original vectors,
%you can pick every 5th element to represent the new grid location:
lat_10km = lat_2km(1:5:end);
lon_10km = lon_2km(1:5:end);
For a better understanding of the above solution, refer to the following MATLAB documentations:
  1. reshape : https://www.mathworks.com/help/matlab/ref/double.reshape.html
  2. mean : https://www.mathworks.com/help/matlab/ref/mean.html
  3. squeeze : https://www.mathworks.com/help/matlab/ref/squeeze.html

Categorías

Más información sobre Reference Applications en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by