xrspatial.proximity.allocation(raster: xarray.core.dataarray.DataArray, x: str = 'x', y: str = 'y', target_values: list = [], distance_metric: str = 'EUCLIDEAN')[source]

Calculates, for all pixels in the input raster, the nearest source based on a set of target values and a distance metric.

This function attempts to produce the value of nearest feature of all pixels in the image to a set of pixels in the source image. The following options are used to define the behavior of the function. By default all non-zero pixels in raster.values will be considered as “target”, and all allocation will be computed in pixels.

raster: xarray.DataArray

2D image array

x: str (default = “x”)

Name of x-coordinates.

y: str (default = “y”)

Name of y-coordinates.

target_values: list

Target pixel values to measure the distance from. If this option is not provided, allocation will be computed from non-zero pixel values. Currently pixel values are internally processed as integers.

distance_metric: str (default = “EUCLIDEAN”)

The metric for calculating distance between 2 points. Valid distance_metrics: ‘EUCLIDEAN’, ‘GREAT_CIRCLE’, and ‘MANHATTAN’

allocation: xarray.DataArray

2D proximity allocation array, of the same type as the input All other input attributes are preserved.

Algorithm References: - OSGeo/gdal, https://github.com/OSGeo/gdal/blob/master/gdal/alg/gdalproximity.cpp, Apr. 22, 2021. # noqa