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
  1 件のコメント
Umi Pollmann
Umi Pollmann 2021 年 5 月 11 日
Has this issue been resolved? I face the same issue at the moment. Thank you.

サインインしてコメントする。

回答 (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]);
Suman
Suman 2023 年 11 月 14 日
Where to insert this code?

サインインしてコメントする。


abbas zoulikha
abbas zoulikha 2020 年 11 月 11 日
i have the same error in my script how did you resolved this errors ?

カテゴリ

Help Center および File ExchangeNetCDF についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by