# How to perform regridding (1.0d to 0.5d) using bilinear interpolation for an irregular area?

I need to regrid temperature dataset from 1 degree to 0.5 degree. In case we have data available for all grids falling in a square, as shown below, we can simply regrid it using bilinear/bicubic interpolation method in MATLAB.

But, the data grids which I have forms an irregular shape i.e., there are no values outsie the given grids as shown below.

How to do regriding in this case ?

• I'm afraid that it depends on the application. What kind of interpolation and extrapolation you are using and what the border represents. Is there e.g heat flux to cells not included in your model or is it a closed system? – Tactopoda Aug 16 '15 at 22:33
• I am trying to regrid temperature. Border represent the state or county. There are no fluxes. – Mario Aug 17 '15 at 7:09
• I suspect your general approach should be to find the concave hull of your original points, then do any form of interpolation (provided it ignores missing values rather than treating them as zero), and then use that concave hull as a mask to remove unwanted points. The tricky part, though, is the concave hull - I don't know how to do that in Matlab, which is why I'm not putting this as an answer. – Semidiurnal Simon Aug 17 '15 at 15:36
• It's been a while since I've done it, but I believe the GrADS program is pretty good with various regridding... and you can use a mask to prevent spillover onto points you don't want. – JeopardyTempest Mar 12 '17 at 21:18
• Would you consider other tools than Matlab? I know how to do this in R, there is a function that allows interpolation into an irregular grid. – Janina Mar 13 '17 at 14:48

Try something like this:

[x_grid,y_grid] = meshgrid(1:100,1:100);
z_grid=griddata(x_data,y_data,z_data,x_grid(:),y_grid(:),'v4');


You can change the method of interpolation if you prefer something else.

Did you try inpainting methods? Inpainting methods try to replace missing data using the existent data. I suggest you check the inpaint_nans.m function in fileexchange.

For example

 [x,y] = meshgrid(0:.01:1);
z0 = exp(x+y);
znan = z0;
znan(20:50,40:70) = NaN;
znan(30:90,5:10) = NaN;
znan(70:75,40:90) = NaN;

z = inpaint_nans(znan);

figure,imagesc(znan),axis image
figure,imagesc(z),axis image