xrspatial.proximity.direction

xrspatial.proximity.direction(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 direction to nearest source based on a set of target values and a distance metric.

This function attempts to calculate for each cell, the the direction, in degrees, to the nearest source. The output values are based on compass directions, where 90 is for the east, 180 for the south, 270 for the west, 360 for the north, and 0 for the source cell itself. 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 array image with shape = (height, width)

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’

direction: xarray.DataArray

2D proximity direction 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