MATLAB Answers

Bilinear interpolation of gridded data

33 views (last 30 days)
Diljit Dutta
Diljit Dutta on 11 Sep 2019
Commented: darova on 12 Sep 2019
I have GCM data for a region with grid size of 2.81 x 2.79 degree(lat x lon) where starting latitude range is 4.9 degree to 41 degree and longitude range is 59 degree to 110 degree. So i need to interpolate this data on a 2.5 X 2.5 degree with latitude range 5-40 degree and longitude range 60-100 degree. how do i use the meshgrid aND LOOPS to do the interpolation

  2 Comments

darova
darova on 11 Sep 2019
Can you attach your data?
Diljit Dutta
Diljit Dutta on 12 Sep 2019
here I have attached the tabular data of variables.. which is a 3D array of 23x14x3355. where 23 is number of longitudes from 59.06 - 120.93 degree with spacing of 2.81 degree and 14 is number of latitudes from 4.18 - 40.46 degree and 3355 is the time scale daily data for 3355 days. Now it is needed to be interpolated on 2.5 x 2.5 scale with longitude range 60-100 and latitude range 5-40 degree.

Sign in to comment.

Accepted Answer

darova
darova on 12 Sep 2019
Hi! This how i do this
clc,clear
load Variables.mat
[m,n,k] = size(predictor);
lon = linspace(59.06,120.93, m);
lat = linspace(4.18,40.46, n);
lon1 = 60:2.5:100; % new range
lat1 = 5: 2.5:40;
[LAT, LON] = meshgrid(lat,lon); % original mesh
[LAT1, LON1] = meshgrid(lat1,lon1); % new mesh
predictor1 = zeros([size(LAT1) k] ); % preallocation
for i = 1:k
pred = predictor(:,:,i);
predictor1(:,:,i) = interp2(LAT,LON,pred,LAT1,LON1);
end
% DRAW SOMETHING !
R = predictor(:,:,1);
R1 = predictor1(:,:,1);
s = pi/180;
[x,y,z] = sph2cart(LAT*s,LON*s,R);
[x1,y1,z1] = sph2cart(LAT1*s,LON1*s,R1);
%%
plot3(x,y,z,'b') % original data: blue lines
hold on
surf(x1,y1,z1) % interpolated data: color surface
hold off
axis equal

  5 Comments

Show 2 older comments
darova
darova on 12 Sep 2019
You can plot something like this
surf(LAT,LON,R)
BUt what is it? How to understand it?
Diljit Dutta
Diljit Dutta on 12 Sep 2019
ok I thought surf(LAT,LON,R) would give a variation of the parameter over a region given by the coordinates. So on this data I further need to do bias correction by Quantile matching with a observed field data. So for that how do I proceed. Can u suggest.
darova
darova on 12 Sep 2019
I know nothing about such correction. Sorry

Sign in to comment.

More Answers (1)

Nicolas B.
Nicolas B. on 11 Sep 2019
Hi,
may I recommand you to take a look at the function griddedInterpolant to solve your case? It will be definitely faster than a solution with loops.
Regards

  3 Comments

Diljit Dutta
Diljit Dutta on 12 Sep 2019
for that i need to convert tabular data to some where everything is assigned to particular latitude and longitude. I am having problem with that
Nicolas B.
Nicolas B. on 12 Sep 2019
Do you have any example of typical input data?
Diljit Dutta
Diljit Dutta on 12 Sep 2019
here I have attached the tabular data of variables.. which is a 3D array of 23x14x3355. where 23 is number of longitudes from 59.06 - 120.93 degree with spacing of 2.81 degree and 14 is number of latitudes from 4.18 - 40.46 degree and 3355 is the time scale daily data for 3355 days. Now it is needed to be interpolated on 2.5 x 2.5 scale with longitude range 60-100 and latitude range 5-40 degree.

Sign in to comment.