I want to interpolate a given 3D point cloud:
I had a look at scipy.interpolate.griddata and the result is exactly what I need, but as I understand, I need to input "griddata" which means something like x = [[0,0,0],[1,1,1],[2,2,2]]
.
But my given 3D point cloud don't has this grid-look - The x,y-values don't behave like a grid - anyway there is only a single z-value for each x,y-value.*
So is there an alternative to scipy.interpolate.griddata for my not-in-a-grid-point-cloud?
*edit: "no grid look" means my input looks like this:
x = [0,4,17]
y = [-7,25,116]
z = [50,112,47]
interpolate. griddata() method is used to interpolate on a 2-Dimension grid.
The interp1d class in the scipy. interpolate is a convenient method to create a function based on fixed data points, which can be evaluated anywhere within the domain defined by the given data using linear interpolation. By using the above data, let us create a interpolate function and draw a new interpolated graph.
This is a function I use for this kind of stuff:
from numpy import linspace, meshgrid
def grid(x, y, z, resX=100, resY=100):
"Convert 3 column data to matplotlib grid"
xi = linspace(min(x), max(x), resX)
yi = linspace(min(y), max(y), resY)
Z = griddata(x, y, z, xi, yi)
X, Y = meshgrid(xi, yi)
return X, Y, Z
Then use it like this:
X, Y, Z = grid(x, y, z)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With