ds.rst.interp_at_points() or Raster.interp_at_points()#
- RasterBase.interp_at_points(points, method=None, nodata_handling=None, band=1, input_latlon=False, as_array=False, shift_area_or_point=None, mp_config=None, error_structure=None, *, resampling=None, backend='auto', resampling_kwargs=None, **kwargs)[source]#
Interpolate raster values at a set of points.
- Overloads:
points (
tuple[int|float|integer[Any] |floating[Any],int|float|integer[Any] |floating[Any]] |tuple[NDArray[floating[Any] |integer[Any]],NDArray[floating[Any] |integer[Any]]] |PointCloudBase|GeoDataFrame|DataArray), method (Literal['nearest','linear','cubic','quintic','slinear','pchip','splinef2d'] |Interpolator) =None, nodata_handling (Literal['nearest','ignore','propagate'] |Literal['half_order_up','half_order_down'] |int|None) =None, band (int) =1, input_latlon (bool) =False, *, as_array (Literal[False]) =False, shift_area_or_point (bool|None) =None, mp_config (MultiprocConfig|None) =None, error_structure (ErrorStructure|None) =None, resampling (Literal['nearest','linear','bilinear','cubic','cubic_convolution','cubic_spline','lanczos','quintic','slinear','pchip','splinef2d','idw','inv_dist','kriging','mean','average','sum','median','med','quantile','q1','q3','mode','minimum','min','maximum','max','range','count','stdev','std','standard_deviation','rms','rmse','average_distance','average_distance_pts'] |Interpolator|None) =None, backend (Literal['auto','gdal','scipy','numba','gstools','gpytorch']) ='auto', resampling_kwargs (dict[str,Any] |None) =None, **kwargs (Any) →PointCloudpoints (
tuple[int|float|integer[Any] |floating[Any],int|float|integer[Any] |floating[Any]] |tuple[NDArray[floating[Any] |integer[Any]],NDArray[floating[Any] |integer[Any]]] |PointCloudBase|GeoDataFrame|DataArray), method (Literal['nearest','linear','cubic','quintic','slinear','pchip','splinef2d'] |Interpolator) =None, nodata_handling (Literal['nearest','ignore','propagate'] |Literal['half_order_up','half_order_down'] |int|None) =None, band (int) =1, input_latlon (bool) =False, *, as_array (Literal[True]), shift_area_or_point (bool|None) =None, mp_config (MultiprocConfig|None) =None, error_structure (ErrorStructure|None) =None, resampling (Literal['nearest','linear','bilinear','cubic','cubic_convolution','cubic_spline','lanczos','quintic','slinear','pchip','splinef2d','idw','inv_dist','kriging','mean','average','sum','median','med','quantile','q1','q3','mode','minimum','min','maximum','max','range','count','stdev','std','standard_deviation','rms','rmse','average_distance','average_distance_pts'] |Interpolator|None) =None, backend (Literal['auto','gdal','scipy','numba','gstools','gpytorch']) ='auto', resampling_kwargs (dict[str,Any] |None) =None, **kwargs (Any) →NDArray[floating[Any] |integer[Any]]points (
tuple[int|float|integer[Any] |floating[Any],int|float|integer[Any] |floating[Any]] |tuple[NDArray[floating[Any] |integer[Any]],NDArray[floating[Any] |integer[Any]]] |PointCloudBase|GeoDataFrame|DataArray), method (Literal['nearest','linear','cubic','quintic','slinear','pchip','splinef2d'] |Interpolator) =None, nodata_handling (Literal['nearest','ignore','propagate'] |Literal['half_order_up','half_order_down'] |int|None) =None, band (int) =1, input_latlon (bool) =False, *, as_array (bool) =False, shift_area_or_point (bool|None) =None, mp_config (MultiprocConfig|None) =None, error_structure (ErrorStructure|None) =None, resampling (Literal['nearest','linear','bilinear','cubic','cubic_convolution','cubic_spline','lanczos','quintic','slinear','pchip','splinef2d','idw','inv_dist','kriging','mean','average','sum','median','med','quantile','q1','q3','mode','minimum','min','maximum','max','range','count','stdev','std','standard_deviation','rms','rmse','average_distance','average_distance_pts'] |Interpolator|None) =None, backend (Literal['auto','gdal','scipy','numba','gstools','gpytorch']) ='auto', resampling_kwargs (dict[str,Any] |None) =None, **kwargs (Any) →NDArray[floating[Any] |integer[Any]] |PointCloud
Returns a point cloud containing the interpolated values at the point coordinates, or optionally an array.
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.
This method forwards its options to resample_at_points().
- Parameters:
points (
tuple[NDArray[floating[Any] |integer[Any]],NDArray[floating[Any] |integer[Any]]] |tuple[int|float|integer[Any] |floating[Any],int|float|integer[Any] |floating[Any]] |PointCloudBase|GeoDataFrame|DataArray) – 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'] |Interpolator) – Interpolator or one of ‘nearest’, ‘linear’, ‘cubic’, ‘quintic’, ‘slinear’, ‘pchip’ or ‘splinef2d’. String methods use the existing SciPy array functions. A custom Interpolator defines the calculation for source cells at fixed GridNeighbours offsets. Defaults to the configured interpolation method.resampling (
Literal['nearest','linear','bilinear','cubic','cubic_convolution','cubic_spline','lanczos','quintic','slinear','pchip','splinef2d','idw','inv_dist','kriging','mean','average','sum','median','med','quantile','q1','q3','mode','minimum','min','maximum','max','range','count','stdev','std','standard_deviation','rms','rmse','average_distance','average_distance_pts'] |Interpolator|None) – Built-in interpolation name, such as “nearest” or “linear”, or an advanced Interpolator. method remains an alias; defaults to the configured interpolation method.backend (
Literal['auto','gdal','scipy','numba','gstools','gpytorch']) – “auto” uses SciPy; “gstools” and “gpytorch” select a kriging solver.resampling_kwargs (
dict[str,Any] |None) – Settings for the named interpolation, including a fitted model for kriging.nodata_handling (
Literal['nearest','ignore','propagate'] |Literal['half_order_up','half_order_down'] |int|None) –"nearest"masks values whose nearest source cell is missing;"ignore"uses available finite cells;"propagate"masks values using a missing source cell. A non-negative integer or half-order choice instead masks cells within that distance of missing source values. Defaults to geoutils.config[“interpolation_nodata_handling”], which is"nearest"unless changed.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 an array of interpolated values instead of a point cloud.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”].error_structure (
ErrorStructure|None) – Optional observation error model used for weighting and fitting. Use geoutils.uncertainty.propagate() to calculate output uncertainty.
:returns Point cloud of interpolated points, or 1D array of interpolated values.