revrt.find_paths#

find_paths(zarr_fp, cost_function, start, end, cache_size=250000000)#

Find least-cost paths for one or more starting points.

This function determined the least cost path for one or more starting points to one or more ending points. A unique path is returned for every starting point, but each route terminates when any of the ending points are found. To ensure that a path is found to every end point, call this function N times if you have N end points and pass a single end point each time.

Parameters:
  • zarr_fp (path-like) – Path to zarr file containing cost layers.

  • cost_function (str) – JSON string representation of the cost function. The following keys are allowed in the cost function: “cost_layers”, “friction_layers”, and “ignore_invalid_costs”. See the documentation of the cost function for details on each of these inputs.

  • start (list of tuple) – List of two-tuples containing non-negative integers representing the indices in the array for the pixel from which routing should begin. A unique path will be returned for each of the starting points.

  • end (list of tuple) – List of two-tuples containing non-negative integers representing the indices in the array for the any allowed final pixel. When the algorithm reaches any of these points, the routing is terminated and the final path + cost is returned.

  • cache_size (int, default 250_000_000) – Cache size to use for computation, in bytes. By default, 250,000,000 (250MB).

Returns:

list of tuple – List of path routing results. Each result is a tuple where the first element is a list of points that the route goes through and the second element is the final route cost.