0

I have a dataframe (120,238), with 12 values spread across it. I am trying to use radial interpolation to fill up the remaining empty points. For that I created an list with the coordinates of the points, and another list with the values of each of these points.

        for i in range(238):
        col.append('')

        df_map = pd.DataFrame(columns = col, index = range(120))
        x_rbf = [8, 227, 19, 116, 11, 223, 5, 231, 116, 116, 13, 222] #x represents the columns
        y_rbf = [59, 59, 102, 111, 17, 17, 9, 9, 62, 17, 7, 7] #y represents the rows
        z_rbf = [16.2,15.99,16.2,16.3,15.7,15,14.2,14.2,16.4,16.4,13,11]

        y = x_rbf, y_rbf
        f = scipy.interpolate.RBFInterpolator(y,z_rbf)

However, when I run this code, I get the following error'

    ValueError: Expected the first axis of `d` to have length 2.

Does anyone know how to go around this?

1 Answers1

0

After countless tries, I figured out the issue with utilizing the RBF Interpolator. The x and y coordinates have to be flattened (using np.ravel()), and then stacked into one array

        for i in range(238):
        col.append('')

        df_map = pd.DataFrame(columns = col, index = range(120))
        x_rbf = [8, 227, 19, 116, 11, 223, 5, 231, 116, 116, 13, 222] #x represents the columns
        y_rbf = [59, 59, 102, 111, 17, 17, 9, 9, 62, 17, 7, 7] #y represents the rows
        z_rbf = [16.2,15.99,16.2,16.3,15.7,15,14.2,14.2,16.4,16.4,13,11]

        sp = np.stack([y_rbf.ravel(),x_rbf.ravel()],-1)
        f = scipy.interpolate.RBFInterpolator(sp,z_rbf.ravel(), kernel = 'linear')

Should work this way