Focal#

Caution

Focal operations use dask.array.map_overlap. Each chunk dimension must be larger than the kernel depth (typically 1 cell for a 3x3 kernel). Chunks smaller than the depth produce wrong results.

Note

mean and focal_stats output float32; hotspots outputs int8 confidence bands. Both mean and hotspots exclude NaN neighbours from their neighbourhood computation.

Apply#

xrspatial.focal.apply([agg, kernel, func, ...])

Returns custom function applied array using a user-created window.

Hotspots#

xrspatial.focal.hotspots([agg, kernel, ...])

Identify statistically significant hot spots and cold spots in an input raster using the Getis-Ord Gi* statistic.

Mean#

xrspatial.focal.mean(agg[, passes, ...])

Returns Mean filtered array using a 3x3 window.

Bilateral#

xrspatial.bilateral.bilateral(agg[, ...])

Apply a bilateral filter for feature-preserving smoothing.

GLCM Texture#

xrspatial.glcm.glcm_texture(agg[, metric, ...])

Compute GLCM texture metrics over a sliding window.

Edge Detection#

xrspatial.edge_detection.sobel_x(agg[, ...])

Compute the horizontal gradient of a raster using the Sobel operator.

xrspatial.edge_detection.sobel_y(agg[, ...])

Compute the vertical gradient of a raster using the Sobel operator.

xrspatial.edge_detection.laplacian(agg[, ...])

Compute edges using the Laplacian (second-derivative) operator.

xrspatial.edge_detection.prewitt_x(agg[, ...])

Compute the horizontal gradient of a raster using the Prewitt operator.

xrspatial.edge_detection.prewitt_y(agg[, ...])

Compute the vertical gradient of a raster using the Prewitt operator.

Focal Statistics#

xrspatial.convolution.convolution_2d(agg, kernel)

Calculates, for all inner cells of an array, the 2D convolution of each cell.

xrspatial.convolution.annulus_kernel(...)

Generates an annulus (ring-shaped) kernel of a given cellsize and radius.

xrspatial.convolution.calc_cellsize(raster)

Calculates cell size of an array based on its attributes.

xrspatial.convolution.circle_kernel(...)

Generates a circular kernel of a given cellsize and radius.

xrspatial.focal.custom_kernel(kernel)

Validates a custom kernel.

xrspatial.focal.focal_stats(agg, kernel[, ...])

Calculates statistics of the values within a specified focal neighborhood for each pixel in an input raster.