cost

This module contains functions to calculate an (euclidean) and influence weighted distance transform

Functions

calculate_dt calculates euclidean distance transform.
calculate_iwdt calculates influence weighted distance transform
calculate_dt()

calculates euclidean distance transform.

Parameters:
  • dt (2D numpy array) – array with source cells initiated to zero and remaining cells to a large none-zero value (typically 999999.0)
  • cellsize (float) – cellsize
  • option (int) –

    parameter used to determine the output:

    1. Returns dt, blx, bly (backlinks). Default
    2. Return dt only
    3. Returns blx, bly (backlinks)
Returns:

  • dt (2D numpy array, *optional*) – distance transform
  • blx, bly (2D numpy arrays, *optional*) – distance transform backlinks

Notes

This is a wrapper for the cython function cy_calculate_dt()

calculate_iwdt()

calculates influence weighted distance transform

Parameters:
  • iwdt (2D numpy array) – array with source cells initiated to zero and remaining cells to a large none-zero value (typically 999999.0)
  • iwdt_dict (dictionary) – dictionary containing information needed to calculate iwdt (see Notes below)
  • option (int) –

    parameter used to determine the output:

    1. Returns iwdt, blx, bly (backlinks). Default
    2. Return iwdt only
    3. Returns blx, bly (backlinks)
Returns:

  • iwdt (2D numpy array, *optional*) – influence weighted distance transform
  • blx, bly (2D numpy arrays, *optional*) – influence weighted distance transform backlinks

Notes

Wrapper function for the cython function cy_calculate_iwdt(). To calculate influence weighted distance transform, it is necessary to generate a dictionary (iwdt_dict{}) with the following entries:

  • ‘dem:’ - 2D numpy array array with elevation data
  • ‘netcost:’ - 2D numpy array array with values between 0 and 1. Must have the same dimensions as *dem
  • ‘cellsize:’ - float cellsize
  • ‘weight:’- float weight associated with netcost. Must be a value between 0 and 1
  • ‘coef:’- numpy array coefficients for polynomial mapping gradient to cost