How to Regrid the netcdf data in order to achieve smaller/greater spatial resolution?

조회 수: 16 (최근 30일)
BN
BN 2019년 10월 6일
댓글: Suman 2023년 11월 14일
I have a netcdf file with 0.5*0.5 degree (Lat*Lon) grided resolution for precipitation from 1982-2015 in all around the globe. now I want to interpolate (regrid) this file to 0.25*0.25 degree without changing the time. In fact I want to interpolate the precipitation data in 0.25*0.25 lat and lon.
please help me with this issue. If it is possible a sample code can really helpful for me.
Best Regards,
Behzad

답변 (2개)

Chad Greene
Chad Greene 2019년 10월 7일
Hey Behzad,
This is pretty straightforward: Just use interp2.
When reading the data from the NetCDF file you might need to rotate and flip the grid to get the orientation right, but then let longitude act as the x variable and let latitude act as the y variable.
You can create the quarter-degree grid in one step with cdtgrid like this:
[lati,loni] = cdtgrid(1/4);
or you can create it manually by
[loni,lati] = meshgrid(min(lon):1/4max(lon),max(lat):-1/4:min(lat));
Then use interp2 like
zi = interp2(lon,lat,z,loni,lati);
Hope that helps.
  댓글 수: 3
O.Hubert
O.Hubert 2022년 3월 16일
You probably figured it out by now, but the error you have arises because you try to transpose a 3-dimensional array (longitude, latitude, time) using a shorthand for 2-dimensional arrays. If you want to transpose longitude and latitude without touching the time dimension, use:
new_array = permute(old_array,[2 1 3]);

댓글을 달려면 로그인하십시오.


abbas zoulikha
abbas zoulikha 2020년 11월 11일
i have the same error in my script how did you resolved this errors ?

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by