⚠️ Our 0.1 release refactored several early-development functions for long-term stability, to update your code see here. ⚠️
Future changes will come with deprecation warnings! 🙂

geoutils.Raster.value_at_coords

geoutils.Raster.value_at_coords#

Raster.value_at_coords(x, y, latlon=False, band=None, masked=False, window=None, reducer_function=<numpy.ma.core._frommethod object>, return_window=False, boundless=True)[source]#

Extract raster values at the nearest pixels from the specified coordinates, or reduced (e.g., mean of pixels) from a window around the specified coordinates.

By default, samples pixel value of each band. Can be passed a band index to sample from.

Parameters:
Return type:

Any

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)