raster_tools.distance.pa_allocation#

raster_tools.distance.pa_allocation(raster, target_values=None, distance_metric='euclidean', max_distance=inf, double_precision=False)[source]#

Compute the proximity allocation of each cell to the closest source cell.

Allocation assigns each raster cell the value of the nearest source cell. This function takes a source raster and uses it to compute a proximity allocation raster. For large max_distance values, this forms the raster analogue of a Voronoi diagram. distance_metric selects the function to use for calculating distances between cells.

This is very similar to ESRI’s Euclidean Allocation tool.

Parameters
  • raster (Raster, path str) – The input source raster. If target_values is not specified or empty, any non-null, finite, non-zero cell is considered a source. If target_values is specified, it will be used to find source cells with the given values.

  • target_values (array-like, optional) – A 1D sequence of values to use to find source cells in raster. If not specified, all non-null, finite, non-zero cells are considered sources.

  • max_distance (scalar, optional) – The maximum distance (in georeferenced units) to consider when computing proximities. Distances greater than this value will not be computed and the corresponding cells will be skipped. This value also determines how much of raster is loaded into memory when carrying out the computation. A larger value produces a larger memory footprint. The default is infinity which causes the entire raster to be loaded at computation time. No cells will be skipped in this case.

  • distance_metric (str) –

    The name of the distance metric to use for computing distances. Default is ‘euclidean’.

    ’euclidean’

    The euclidean distance between two points: sqrt((x1 - x2)^2 + (y1 - y2)^2)

    ’taxi’ ‘taxicab’ ‘manhatten’ ‘city_block’

    The taxicab distance between two points: |x1 - x2| + |y1 - y2|

    ’chebyshev’ ‘chessboard’

    The chebyshev or chessboard distance: max(|x1 - x2|, |y1 - y2|)

    ’haversine’ ‘great_circle’

    The great circle distance between points on a sphere. This implementation uses the WGS84 mean earth radius of 6,371,009 m. Coordinates are assumed to be in degrees. Latitude must be in the range [-90, 90] and longitude must be in the range [-180, 180].

  • double_precision (bool) – If True, distances will will be computed with 64-bit precision, otherwise 32-bit floats are used. Default is False.

Returns

The allocation raster.

Return type

Raster

References