raster_tools.distance.proximity_analysis#

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

Compute the proximity, allocation, and direction for a given source raster.

This function uses proximity analysis to compute the proximity, allocation, and direction rasters for a given source raster. See the individual functions for more details:

This is very similar to ESRI’s Proximity Analysis tools.

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

  • proximity (Raster) – The proximity raster.

  • direction (Raster) – The direction raster.

  • allocation (Raster) – The allocation raster.

References