I have a relatively large (spatially) irregular grid. It consists of multiple curvilinear grids (see example) of which I have all the x, y coordinates and the z-value (height) of the individual cells.
These cells can be in the order of 50m x 50m.
I would like to interpolate this to a 1m x 1m grid, how would one do such a thing efficiently in python?
If possible I would like to not create a grid which also spans the regions without grid cells since I think it is likely that the interpolated dataset will be quite large.
EDIT: tried to do 2D interpolation in python but cant get it to work I found this script: http://scipy-cookbook.readthedocs.io/items/Matplotlib_Gridding_irregularly_spaced_data.html
From this example I tried to do the same but get only nan values. The script:
XZ2 = XZ[XZ != 0.].ravel()
YZ2 = YZ[YZ != 0.].ravel()
dps2 = dps[XZ != 0.].ravel()
# define grid.
xi = np.arange(math.floor(min(XZ2)), math.ceil(max(XZ2))+1, 1)
yi = np.arange(math.floor(min(YZ2)), math.ceil(max(YZ2))+1, 1)
# grid the data.
zi = griddata((XZ2, YZ2), dps, (xi[None,:], yi[:,None]), method='linear')
Any idea why?
I didn't do it in QGis because I feel I should be able to do this in python..
Thanks