xrspatial.focal.hotspots#

xrspatial.focal.hotspots(raster, kernel)[source]#

Identify statistically significant hot spots and cold spots in an input raster. To be a statistically significant hot spot, a feature will have a high value and be surrounded by other features with high values as well. Neighborhood of a feature defined by the input kernel, which currently support a shape of circle, annulus, or custom kernel.

The result should be a raster with the following 7 values:
  • 90 for 90% confidence high value cluster

  • 95 for 95% confidence high value cluster

  • 99 for 99% confidence high value cluster

  • 90 for 90% confidence low value cluster

  • 95 for 95% confidence low value cluster

  • 99 for 99% confidence low value cluster

  • 0 for no significance

Parameters
  • raster (xarray.DataArray) – 2D Input raster image with raster.shape = (height, width). Can be a NumPy backed, CuPy backed, or Dask with NumPy backed DataArray

  • kernel (Numpy Array) – 2D array where values of 1 indicate the kernel.

Returns

hotspots_agg – 2D array of hotspots with values indicating confidence level.

Return type

xarray.DataArray of same type as raster

Examples

>>> import numpy as np
>>> import xarray as xr
>>> from xrspatial.convolution import custom_kernel
>>> kernel = custom_kernel(np.array([[1, 1, 0]]))
>>> data = np.array([
...    [0, 1000, 1000, 0, 0, 0],
...    [0, 0, 0, -1000, -1000, 0],
...    [0, -900, -900, 0, 0, 0],
...    [0, 100, 1000, 0, 0, 0]])
>>> from xrspatial.focal import hotspots
>>> hotspots(xr.DataArray(data), kernel)
array([[  0,   0,  95,   0,   0,   0],
       [  0,   0,   0,   0, -90,   0],
       [  0,   0, -90,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0]], dtype=int8)
Dimensions without coordinates: dim_0, dim_1