

Which means (I believe) something as that there's not enough coordinates.

Raise TypeError('m >= (kx+1)(ky+1) must hold') Self.tck = fitpack.bisplrep(x, y, z, kx=kx, ky=ky, s=0.0)įile "C:\Python27\ArcGIS10.5\lib\site-packages\scipy\interpolate\fitpack.py", line 929, in bisplrep Some = 2d(xx, yy, zz)įile "C:\Python27\ArcGIS10.5\lib\site-packages\scipy\interpolate\interpolate.py", line 229, in _init_ I have been looking at 2d but that returns the error: Traceback (most recent call last):įile "D:\ARNO\JarkusPython\ARNO\Create_Data\createStraightData.py", line 50, in The yellow point with the circle around t is the x and y coordinate that I have to find: The green and the red lines are the known points and the blue line between those points is a slope that I could calculate I suspect. The (very basic.) illustration below illustrates what I mean. The data must be defined on a rectilinear grid that is, a rectangular grid with even. Extrapolation tips and tricks interp1d : replicate numpy.
#INTERPOLATE NUMPY RASTER X Y Z CODE#
If x and y represent a regular grid, consider using RectBivariateSpline. Interpolation on a regular or rectilinear grid in arbitrary dimensions. You can interpolate the two axes independently like: Code def findxy (p1, p2, z): x1, y1, z1 p1 x2, y2, z2 p2 if z2 < z1: return findxy (p2, p1, z) x np.interp (z, (z1, z2), (x1, x2)) y np. This class returns a function whose call method uses spline interpolation to find the value of new points. In more detail: I have a csv-file with x y and z values and I need to find the place where the 0, z value is crossed. x, y and z are arrays of values used to approximate some function f: z f (x, y). (1600, 1600, -76.322, 30.I need to find the x and y coordinate on a known z coordinate based on two known xyz coordinates. Parser.add_argument("filename",help='raster file from which to interpolate a (1/3,1/3) point from from') Thank you for the hints in your question. version = 0.14.0, it happily works on some 1600x1600 model output. I get the same error as you do with scipy. We take a set of points xi, yi for i 0, 1,, n for the function y f (x). Splines are polynomial that are smooth and continuous across a given plot and also continuous first and second derivatives where they join. I think older versions assume irregular grids and don't take advantage of the regular grids. Cubic spline interpolation is a way of finding a curve that connects data points with a degree of three or less. astype(band_array.dtype) to make the output data type the same as the input array. Note that the result will be returned with an apparent higher precision than the source data, since it is up-classed to NumPy's dtype('float64') data type. # Use the differences to weigh the four raster values # Calculate differences from point to bounding raster midpoints # Test array bounds to ensure point is within raster midpoints # Special case where point is on upper bounds # Calculate raster lower bound indices from point I've translated the formula below (from Wikipedia) into Python-speak to yield the following algorithm, which appears to work. but I much prefer bilinear interpolation methods) (Note: the nearest neighbor interpolation algorithm is easy cake: from numpy import argmin, NANĭef nearest_neighbor(px, py, no_data=NAN): Is there an R package that does X, Y, Z, V interpolation I see that Akima does X, Y, V but I need one more dimension. Has anyone come across a good bilinear interpolation algorithm, preferably in Python, possibly tailored with NumPy? Any hints or advice? I don't see why I should have a memory error, since my raster is 317×301, and the bilinear algorithm should not be difficult. I'll admit, I have limited confidence in this SciPy function, as the bounds_error or fill_value parameters don't work as documented. Self.tck = fitpack.bisplrep(self.x, self.y, self.z, kx=kx, ky=ky, s=0.)įile "C:\Python25\Lib\site-packages\scipy\interpolate\fitpack.py", line 873, in bisplrep
#INTERPOLATE NUMPY RASTER X Y Z WINDOWS#
However I get a memory error on my 32-bit Windows system with a 317×301 raster: Traceback (most recent call last):įile "C:\Python25\Lib\site-packages\scipy\interpolate\interpolate.py", line 125, in _init_ Up to now, I've tried SciPy's interp2d function: from scipy import interpolateīilinterp = interpolate.interp2d(ax, ay, band_array, kind='linear') Nx, ny = source.RasterXSize, source.RasterYSizeīand_array = source.GetRasterBand(1).ReadAsArray()Īx = array( + ix*gt + gt/2.0 for ix in range(nx)])Īy = array( + iy*gt + gt/2.0 for iy in range(ny)]) Here is where I'm at: from osgeo import gdal I have a raster that I'd like to do some point interpolations with.
