<p>Try something like this:</p>

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

<p>You can change the method of interpolation if you prefer something else.</p>

<p>See:
<a href="http://www.mathworks.com/help/matlab/ref/griddata.html" rel="nofollow">http://www.mathworks.com/help/matlab/ref/griddata.html</a></p>

CC BY-SA 3.0
2016-09-15T01:48:03.993Z
2016-09-15T01:48:03.993Z
Antonio
<p>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.</p>

<p>For example</p>

<pre><code> [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
</code></pre>

<p><a href="https://i.sstatic.net/kvnpd.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/kvnpd.png" alt="enter image description here"></a></p>

<p><a href="https://i.sstatic.net/UIjV8.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/UIjV8.png" alt="enter image description here"></a></p>

CC BY-SA 3.0
2017-03-12T20:24:28.717Z
2017-03-12T20:24:28.717Z
Ozcan
<p>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.</p>

<p><a href="https://i.sstatic.net/NnfaS.png" rel="noreferrer"><img src="https://i.sstatic.net/NnfaS.png" alt="enter image description here"></a></p>

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

<p><a href="https://i.sstatic.net/e3yWM.png" rel="noreferrer"><img src="https://i.sstatic.net/e3yWM.png" alt="enter image description here"></a></p>

<p>How to do regriding in this case ?</p>

CC BY-SA 3.0
2015-08-16T22:33:29.730Z
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?
user2821
CC BY-SA 3.0
2015-08-17T07:09:35.290Z
I am trying to regrid temperature. Border represent the state or county.  There are no fluxes.
dsbisht
CC BY-SA 3.0
2015-08-17T15:36:30.453Z
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
CC BY-SA 3.0
2017-03-12T21:18:22.083Z
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
CC BY-SA 3.0
2017-03-13T14:48:49.137Z
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
<meteorology><hydrology><climate-models><matlab>
How to perform regridding (1.0d to 0.5d) using bilinear interpolation for an irregular area?
dsbisht
# How to perform regridding (1.0d to 0.5d) using bilinear interpolation for an irregular area?

(Asked by: username_0 on 2015-08-16)

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.

[![enter image description here](https://i.sstatic.net/NnfaS.png)](https://i.sstatic.net/NnfaS.png)

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

[![enter image description here](https://i.sstatic.net/e3yWM.png)](https://i.sstatic.net/e3yWM.png)

How to do regriding in this case ?

**Tags:** meteorology, hydrology, climate-models, matlab

> **Comments:**
> **username_1**: 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?  
> **username_0**: I am trying to regrid temperature. Border represent the state or county.  There are no fluxes.  
> **username_2**: 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.  
> **username_3**: 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.  
> **username_4**: 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.  

---

## 2 answers

### Answer by username_5 on 2016-09-15. Score: 1

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.

See:
<http://www.mathworks.com/help/matlab/ref/griddata.html>


---

### Answer by username_6 on 2017-03-12. Score: 1

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

```

[![enter image description here](https://i.sstatic.net/kvnpd.png)](https://i.sstatic.net/kvnpd.png)

[![enter image description here](https://i.sstatic.net/UIjV8.png)](https://i.sstatic.net/UIjV8.png)


---

