geoutils.Raster.reduce_points#
- Raster.reduce_points(points, reducer_function=<function mean>, window=None, input_latlon=False, band=None, masked=False, return_window=False, as_array=False, boundless=True)#
Reduce raster values around point coordinates.
By default, samples pixel value of each band. Can be passed a band index to sample from.
Uses Rasterio’s windowed reading to keep memory usage low (for a raster not loaded).
- 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|GeoDataFrame) – 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[tuple[Any,...],dtype[floating[Any] |integer[Any]]]],float]) – Reducer function to apply to the values in window (defaults to np.mean).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.return_window (
bool) – Whether to return the windows (in addition to the reduced value).as_array (
bool) – Whether to return an array of reduced values (defaults to a point cloud containing input coordinates).boundless (
bool) – Whether to allow windows that extend beyond the extent.
- Return type:
- Returns:
Point cloud of interpolated points, or 1D array of interpolated values. In addition, if return_window=True, return tuple of (values, arrays).