reVX.least_cost_xmission.least_cost_paths.LeastCostPaths
- class LeastCostPaths(cost_fpath, features_fpath, clip_buffer=0, tb_layer_name='transmission_barrier')[source]
Bases:
object
Compute least cost paths between desired locations
- Parameters:
cost_fpath (str) – Path to h5 file with cost rasters and other required layers
features_fpath (str) – Path to GeoPackage with transmission features
resolution (int, optional) – SC point resolution, by default 128
clip_buffer (int, optional) – Optional number of array elements to buffer clip area by. By default,
0
.tb_layer_name (str, default=:obj:BARRIER_H5_LAYER_NAME) – Name of transmission barrier layer in cost_fpath file. This layer defines the multipliers applied to the cost layer to determine LCP routing (but does not actually affect output costs). By default,
BARRIER_H5_LAYER_NAME
.
Methods
process_least_cost_paths
(cost_layers[, ...])Find Least Cost Paths between all pairs of provided features for the given tie-line capacity class
run
(cost_fpath, features_fpath, cost_layers)Find Least Cost Paths between all pairs of provided features for the given tie-line capacity class
Attributes
GeoDataFrame containing the transmission features to compute the least cost paths to, starting from the start_indices (typically the centroid of the supply curve cell under consideration).
Tuple (row, col) index or list of (row, col) indices in the cost array indicating the end location(s) to compute least cost paths to (typically transmission feature locations).
Table of features to compute paths for
Tuple of (row_idx, col_idx) in the cost array indicating the start position of all paths to compute (typically, this is the centroid of the supply curve cell under consideration).
- property features
Table of features to compute paths for
- Returns:
pandas.DataFrame
- property start_indices
Tuple of (row_idx, col_idx) in the cost array indicating the start position of all paths to compute (typically, this is the centroid of the supply curve cell under consideration). Paths will be computed from this start location to each of the end_indices, which are also locations in the cost array (typically transmission feature locations).
- Returns:
tuple
- property end_features
GeoDataFrame containing the transmission features to compute the least cost paths to, starting from the start_indices (typically the centroid of the supply curve cell under consideration).
- Returns:
pandas.DataFrame
- property end_indices
Tuple (row, col) index or list of (row, col) indices in the cost array indicating the end location(s) to compute least cost paths to (typically transmission feature locations). Paths are computed from the start_indices (typically the centroid of the supply curve cell under consideration) to each of the individual pairs of end_indices.
- Returns:
tuple | list
- process_least_cost_paths(cost_layers, barrier_mult=100, indices=None, max_workers=None, save_paths=False, length_invariant_cost_layers=None, tracked_layers=None, cell_size=90)[source]
Find Least Cost Paths between all pairs of provided features for the given tie-line capacity class
- Parameters:
cost_layers (List[str]) – List of layers in H5 that are summed to determine total costs raster used for routing. Costs and distances for each individual layer are also reported (e.g. wet and dry costs). deteremining path using main cost layer.
barrier_mult (int, optional) – Transmission barrier multiplier, used when computing the least cost tie-line path, by default 100
indices (iterable, optonal) – Indices of the transmission features input that should be processed. By default
None
, which process all transmission features.max_workers (int, optional) – Number of workers to use for processing, if 1 run in serial, if None use all available cores, by default None
save_paths (bool, optional) – Flag to save least cost path as a multi-line geometry, by default False
length_invariant_cost_layers (List[str] | None, optional) – List of layers in H5 to be added to the cost raster. The costs specified by these layers are not scaled with distance traversed across the cell (i.e. fixed one-time costs for crossing these cells).
tracked_layers (dict, optional) – Dictionary mapping layer names to strings, where the strings are numpy methods that should be applied to the layer along the LCP. For example,
tracked_layers={'layer_1': 'mean', 'layer_2': 'max}
would report the average oflayer_1
values along the least cost path and the max oflayer_2
values along the least cost path. Examples of numpy methods (non-exhaustive):mean
max
min
mode
median
std
By default,
None
, which does not track any extra layers.cell_size (int, optional) – Side length of each cell, in meters. Cells are assumed to be square. By default,
CELL_SIZE
.
- Returns:
least_cost_paths (pandas.DataFrame | gpd.GeoDataFrame) – DataFrame of lengths and costs for each path or GeoDataFrame of length, cost, and geometry for each path
- classmethod run(cost_fpath, features_fpath, cost_layers, clip_buffer=0, tb_layer_name='transmission_barrier', barrier_mult=100, indices=None, max_workers=None, save_paths=False, length_invariant_cost_layers=None, tracked_layers=None, cell_size=90)[source]
Find Least Cost Paths between all pairs of provided features for the given tie-line capacity class
- Parameters:
cost_fpath (str) – Path to h5 file with cost rasters and other required layers
features_fpath (str) – Path to GeoPackage with transmission features
cost_layers (List[str]) – List of layers in H5 that are summed to determine total costs raster used for routing. Costs and distances for each individual layer are also reported (e.g. wet and dry costs). deteremining path using main cost layer.
clip_buffer (int, optional) – Optional number of array elements to buffer clip area by. By default,
0
.tb_layer_name (str, default=:obj:BARRIER_H5_LAYER_NAME) – Name of transmission barrier layer in cost_fpath file. This layer defines the multipliers applied to the cost layer to determine LCP routing (but does not actually affect output costs). By default,
BARRIER_H5_LAYER_NAME
.barrier_mult (int, optional) – Transmission barrier multiplier, used when computing the least cost tie-line path, by default 100
indices (iterable, optonal) – Indices of the transmission features input that should be processed. By default
None
, which process all transmission features.max_workers (int, optional) – Number of workers to use for processing, if 1 run in serial, if None use all available cores, by default None
save_paths (bool, optional) – Flag to save least cost path as a multi-line geometry, by default False
length_invariant_cost_layers (List[str] | None, optional) – List of layers in H5 to be added to the cost raster. The costs specified by these layers are not scaled with distance traversed across the cell (i.e. fixed one-time costs for crossing these cells).
tracked_layers (dict, optional) – Dictionary mapping layer names to strings, where the strings are numpy methods that should be applied to the layer along the LCP. For example,
tracked_layers={'layer_1': 'mean', 'layer_2': 'max}
would report the average oflayer_1
values along the least cost path and the max oflayer_2
values along the least cost path. Examples of numpy methods (non-exhaustive):mean
max
min
mode
median
std
By default,
None
, which does not track any extra layers.cell_size (int, optional) – Side length of each cell, in meters. Cells are assumed to be square. By default,
CELL_SIZE
.
- Returns:
least_cost_paths (pandas.DataFrame | gpd.GeoDataFrame) – DataFrame of lengths and costs for each path or GeoDataFrame of length, cost, and geometry for each path