geoutils.Raster.interp_points#
- Raster.interp_points(points, method='linear', dist_nodata_spread='half_order_up', band=1, input_latlon=False, as_array=False, shift_area_or_point=None, force_scipy_function=None, **kwargs)[source]#
Interpolate raster values at a set of points.
Returns a point cloud with data column the interpolated values at the point coordinates, or optionally just the array of interpolated rvalues.
Uses scipy.ndimage.map_coordinates if the Raster is on an equal grid using “nearest” or “linear” (for speed), otherwise uses scipy.interpn on a regular grid.
Optionally, user can enforce the interpretation of pixel coordinates in self.tags[‘AREA_OR_POINT’] to ensure that the interpolation of points is done at the right location. See parameter description of shift_area_or_point for more details.
- Parameters:
points (
tuple[int|float|integer[Any] |floating[Any],int|float|integer[Any] |floating[Any]] |tuple[ndarray[tuple[Any,...],dtype[floating[Any] |integer[Any]]],ndarray[tuple[Any,...],dtype[floating[Any] |integer[Any]]]] |PointCloud) – Point(s) at which to interpolate raster value. Can be either a tuple of array-like of X/Y coordinates (same CRS as raster or latitude/longitude, see “input_latlon”) or a pointcloud in any CRS. If points fall outside of image, value returned is nan.method (
Literal['nearest','linear','cubic','quintic','slinear','pchip','splinef2d']) – Interpolation method, one of ‘nearest’, ‘linear’, ‘cubic’, ‘quintic’, ‘slinear’, ‘pchip’ or ‘splinef2d’. For more information, see scipy.ndimage.map_coordinates and scipy.interpolate.interpn. Default is linear.dist_nodata_spread (
Literal['half_order_up','half_order_down'] |int) – Distance of nodata spreading during interpolation, either half-interpolation order rounded up (default; equivalent to 0 for nearest, 1 for linear methods, 2 for cubic methods and 3 for quintic method), or rounded down, or a fixed integer.band (
int) – Band to use (from 1 to self.count).input_latlon (
bool) – (Only for tuple point input) Whether to convert input coordinates from latlon to raster CRS.as_array (
bool) – Whether to return a point cloud with data column the interpolated values (default) or an array of interpolated values.shift_area_or_point (
bool|None) – Whether to shift with pixel interpretation, which shifts to center of pixel coordinates if self.area_or_point is “Point” and maintains corner pixel coordinate if it is “Area” or None. Defaults to True. Can be configured with the global setting geoutils.config[“shift_area_or_point”].force_scipy_function (
Literal['map_coordinates','interpn'] |None) – Force to use either map_coordinates or interpn. Mainly for testing purposes.
- Return type:
ndarray[tuple[Any,...],dtype[floating[Any] |integer[Any]]] |PointCloud
:returns Point cloud of interpolated points, or 1D array of interpolated values.