geoutils.Raster.reduce_points#
- Raster.reduce_points(points, reducer_function=<numpy.ma.core._frommethod object>, window=None, input_latlon=False, band=None, masked=False, return_window=False, boundless=True)[source]#
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
[Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]],Union
[Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]]) – Point(s) at which to interpolate raster value (tuple of X/Y array-likes). If points fall outside of image, value returned is nan.reducer_function (
Callable
[[ndarray
[Any
,dtype
[Union
[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
) – Whether the input is in latlon, unregarding of Raster CRSband (
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).boundless (
bool
) – Whether to allow windows that extend beyond the extent.
- Return type:
- Returns:
When called on a raster or with a specific band set, return value of pixel.
- Returns:
If multiple band raster and the band is not specified, a dictionary containing the value of the pixel in each band.
- Returns:
In addition, if return_window=True, return tuple of (values, arrays)
- Examples:
>>> self.value_at_coords(-48.125, 67.8901, window=3) Returns mean of a 3*3 window: v v v v c v | = float(mean) v v v / (c = provided coordinate, v= value of surrounding coordinate)