Regridding Latitude/Longitude File

조회 수: 1 (최근 30일)
YOlivo
YOlivo 2018년 6월 28일
답변: Raag 2025년 2월 17일
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.

답변 (1개)

Raag
Raag 2025년 2월 17일
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

카테고리

Help CenterFile Exchange에서 Reference Applications에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by