Regridding 3D data
10 views (last 30 days)
Show older comments
I have a 3D data with a dimension of Longitude x Latitude x Altitude with a size of 76x40x54. The resolution of the data is 5 degree longitude by 5 degree latitude. I would like to regrid my data to 2 degree longitude by 2 degree latitude. Also I would like my longitude data to vary from 0 to 360 with a increment of 2 degrees (i. e 0 2 4 6 .......356 358) and latitude data to vary from -90 to 90 with a increment of 2 degrees (i.e -90 -88 86 ...0...86 88 90). The altitude resolution will be same. Is it possible to convert all of the variables like Longitude, Latitude and Temperature. I tried to interpolate to regrid the data but I got an error.
Link for the data:shorturl.at/oQSU7
The matlab code:
file='3DALL_t021213_000000.nc';
Temp=ncread(file,'Temperature');
Lat=ncread(file,'Latitude')*180/pi;
Long=ncread(file,'Longitude')*180/pi;
Alt=ncread(file,'Altitude');
Alt = Alt(1,1,:),
Alt = permute(Alt,[1 3 2]);
[LongI,LatI,AltI] = ndgrid(0:2:360,-90:2:90,Alt);
TempI = interpn(Lat,Long,Alt, Temp,LongI,LatI,AltI,'linear');
I am getting this error.
Error using griddedInterpolant
Grid arrays must have NDGRID structure.
Error in interpn (line 151)
F = griddedInterpolant(X{:}, V, method,extrap);
Error in untitled (line 9)
TempI = interpn(Lat,Long,Alt, Temp,LongI,LatI,AltI,'linear');
2 Comments
Answers (1)
Star Strider
on 22 Nov 2022
I am not familiar with Mapping Toolbox requirements (I don’t have it so have no experience with it), so I’m not certain what special requirements may be necessary for your data.
However, it would likely be best to use ndgrid to re-grid the longitude and latitude (not altitude) and then interpolate the altitude. Use either griddedInterpolant or scatteredInterpolant, depending on which is more reliable. (I generally use scatteredInterpolant even for gridded data.)
.
0 Comments
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!