ds.rst.reduce_at_points() or Raster.reduce_at_points()

ds.rst.reduce_at_points() or Raster.reduce_at_points()#

RasterBase.reduce_at_points(points, reducer_function=None, window=None, input_latlon=False, band=None, masked=False, as_array=False, boundless=True, *, coverage=None, window_shape=None, error_structure=None, mp_config=None, resampling=None, backend='auto', resampling_kwargs=None)[source]#

Reduce raster values around point coordinates.

Samples the first band by default, or the requested band. Window reductions share the eager, Dask and multiprocessing paths of resample_at_points(), with overlap covering the selected neighborhood.

Parameters:
  • 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) – 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.

  • reducer_function (Callable[[NDArray[floating[Any] | integer[Any]]], float] | Reducer | None) – Legacy method argument, accepting a Reducer or reduction callable.

  • 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'] | Reducer | None) – Statistic name or an advanced Reducer. Defaults to the mean.

  • backend (Literal['auto', 'gdal', 'scipy', 'numba', 'gstools', 'gpytorch']) – “auto” or “scipy” for window reductions.

  • resampling_kwargs (dict[str, Any] | None) – Settings for a named statistic, such as a quantile q.

  • window (int | None) – Window size to read around coordinates. Must be odd.

  • input_latlon (bool) – (Only for tuple point input) Whether to convert input coordinates from latlon to raster CRS.

  • band (int | None) – Band number to extract from (from 1 to self.count).

  • masked (bool) – Whether to return a masked array, or classic array.

  • as_array (bool) – Whether to return an array of reduced values (defaults to a point cloud containing input coordinates).

  • boundless (bool) – Allow partial windows at raster edges. If False, incomplete windows return NaN.

  • coverage (Literal['center', 'all_touched', 'fractional'] | None) – Select cells by center, include all touched cells, or weight by covered area.

  • window_shape (Literal['square', 'circular'] | None) – Use a square or circular window.

  • error_structure (ErrorStructure | None) – Optional observation error model used for weighting and fitting. Use geoutils.uncertainty.propagate() to calculate output uncertainty.

  • mp_config (MultiprocConfig | None) – Multiprocessing settings for reading and reducing raster tiles.

Return type:

Any

Returns:

Point cloud of reduced values, or a scalar/array when as_array=True.