reVX.least_cost_xmission.trans_cap_costs.ReinforcementLineCosts

class ReinforcementLineCosts(transmission_lines, cost_fpath, start_indices, capacity_class, cost_layers, row_slice, col_slice, xmission_config=None, tb_layer_name='transmission_barrier', barrier_mult=100, length_invariant_cost_layers=None, tracked_layers=None, cell_size=90)[source]

Bases: TieLineCosts

Compute Least Cost Reinforcement Line cost from substations to network nodes.

The reinforcement line path will attempt to follow existing transmission lines for as long as possible. Costs are calculated using half of the greenfield cost of the transmission line that is being traced. If the reinforcement path travels along two different line voltages, corresponding costs are used for each portion of the path. In the case that the path must cross a region with no existing transmission lines to reach the destination, half (50%) of the greenfield cost of the cost_layers input is used.

Parameters:
  • transmission_lines (dict) – Dictionary where the keys are the names of cost layers in the cost HDF5 file and values are clipped arrays with the corresponding existing transmission lines rastered into them (i.e. array value is 1 at a pixel if there is a transmission line, otherwise 0). These arrays will be used to compute the reinforcement costs along existing transmission lines of differing voltages.

  • cost_fpath (str) – Full path of .h5 file with cost arrays.

  • start_indices (tuple) – Tuple of (row_idx, col_idx) in the clipped cost array indicating the start position of all reinforcement line paths to compute (typically, this is the location of the network node in the BA). Paths will be computed from this start location to each of the end_indices, which are also locations in the cost array (typically substations within the BA of the network node).

  • capacity_class (int | str) – Capacity class of the ‘base’ greenfield costs layer. Costs will be scaled by the capacity corresponding to this class to report reinforcement costs as $/MW.

  • cost_layers (List[str]) – List of layers in H5 that are summed to determine total ‘base’ greenfield costs raster used for routing. ‘Base’ greenfield costs are only used if the reinforcement path must deviate from existing transmission lines. Typically, a capacity class of 400 MW (230kV transmission line) is used for the base greenfield costs.

  • row_slice, col_slice (slice) – Row and column slices into the cost array representing the window to compute reinforcement line path within.

  • xmission_config (str | dict | XmissionConfig, optional) – Path to Xmission config .json, dictionary of Xmission config .jsons, or preloaded XmissionConfig objects. By default, None.

  • 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) – Multiplier on transmission barrier costs. By default, 100.

  • length_invariant_cost_layers (List[str] | None, optional) – List of layers in H5 to be added to the ‘base’ greenfield 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 of layer_1 values along the least cost path and the max of layer_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.

Methods

compute(end_indices[, save_paths])

Compute least cost paths to given end indices

least_cost_path(end_idx[, save_path])

Find least cost path, its length, and its total (un-barriered) cost.

run(transmission_lines, cost_fpath, ...[, ...])

Compute reinforcement line path to all features to be connected a single supply curve point.

Attributes

clip_shape

Shaped of clipped cost raster

col

Column index inside clipped array

col_offset

Offset to apply to column indices to move into clipped array

cost

Tie line costs array

mcp

MCP_Geometric instance initialized on mcp_cost array with starting point at sc_point

mcp_cost

Tie line costs array with barrier costs applied for MCP analysis

row

Row index inside clipped array

row_offset

Offset to apply to row indices to move into clipped array

classmethod run(transmission_lines, cost_fpath, start_indices, end_indices, capacity_class, cost_layers, row_slice, col_slice, xmission_config=None, tb_layer_name='transmission_barrier', barrier_mult=100, save_paths=False, length_invariant_cost_layers=None, tracked_layers=None, cell_size=90)[source]

Compute reinforcement line path to all features to be connected a single supply curve point.

Parameters:
  • transmission_lines (dict) – Dictionary where the keys are the names of cost layers in the cost HDF5 file and values are clipped arrays with the corresponding existing transmission lines rastered into them (i.e. array value is 1 at a pixel if there is a transmission line, otherwise 0). These arrays will be used to compute the reinforcement costs along existing transmission lines of differing voltages.

  • cost_fpath (str) – Full path of .h5 file with cost arrays.

  • start_indices (tuple) – Tuple of (row_idx, col_idx) in the clipped cost array indicating the start position of all reinforcement line paths to compute (typically, this is the location of the network node in the BA). Paths will be computed from this start location to each of the end_indices, which are also locations in the cost array (typically substations within the BA of the network node).

  • end_indices (tuple | list) – Tuple (row, col) index or list of (row, col) indices in the clipped cost array indicating the end location(s) to compute reinforcement line paths to (typically substations within a single BA). Paths are computed from the start_indices (typically the network node of the BA) to each of the individual pairs of end_indices.

  • capacity_class (int | str) – Capacity class of the ‘base’ greenfield costs layer. Costs will be scaled by the capacity corresponding to this class to report reinforcement costs as $/MW.

  • cost_layers (List[str]) – List of layers in H5 that are summed to determine total ‘base’ greenfield costs raster used for routing. ‘Base’ greenfield costs are only used if the reinforcement path must deviate from existing transmission lines. Typically, a capacity class of 400 MW (230kV transmission line) is used for the base greenfield costs.

  • row_slice, col_slice (slice) – Row and column slices into the cost array representing the window to compute reinforcement line path within.

  • xmission_config (str | dict | XmissionConfig, optional) – Path to Xmission config .json, dictionary of Xmission config .jsons, or preloaded XmissionConfig objects. By default, None.

  • 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) – Multiplier on transmission barrier costs. By default, 100.

  • save_paths (bool, optional) – Flag to save reinforcement line 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 ‘base’ greenfield 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 of layer_1 values along the least cost path and the max of layer_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:

tie_lines (pandas.DataFrame | gpd.GeoDataFrame) – DataFrame of lengths and costs for each reinforcement line path or GeoDataFrame of length, cost, and geometry for each reinforcement line path.

property clip_shape

Shaped of clipped cost raster

Returns:

tuple

property col

Column index inside clipped array

Returns:

int

property col_offset

Offset to apply to column indices to move into clipped array

Returns:

int

compute(end_indices, save_paths=False)

Compute least cost paths to given end indices

Parameters:
  • end_indices (tuple | list) – Tuple (row, col) index or list of (row, col) indices in the clipped cost array indicating the end location(s) to compute least cost path paths to. Paths are computed from the start_indices that this class was initialized with to each of the individual pairs of end_indices.

  • save_paths (bool, optional) – Flag to save least cost path as a multi-line geometry, by default False

Returns:

tie_lines (pandas.DataFrame | gpd.GeoDataFrame) – DataFrame of lengths and costs for each path or GeoDataFrame of length, cost, and geometry for each path

property cost

Tie line costs array

Returns:

ndarray

least_cost_path(end_idx: Tuple[int, int], save_path=False) Tuple[float, float, float, float, Point | LineString | None, Dict[str, float]]

Find least cost path, its length, and its total (un-barriered) cost. Optionally, calculate separate costs for sub-layers, and geometry of path.

Parameters:
  • end_idx (Tuple[int, int]) – (row, col) index of end point to connect and compute least cost path to.

  • save_path (bool) – Flag to save least cost path as a multi-line geometry. By default, False.

Returns:

  • length (float) – Length of path (km).

  • cost (float) – Cost of path including terrain and land use multipliers, but not barrier costs.

  • poi_lat, poi_lon (numpy.float64) – Latitude and longitude of the end_idx of the least cost path (i.e. the POI/transmission feature that was connected to).

  • path (shapely.geometry.linestring | None, optional) – Path as a LineString, if save_path was set to True.

  • cl_results (Dict[str, float]) – Costs and lengths for individual sub-layers.

property mcp

MCP_Geometric instance initialized on mcp_cost array with starting point at sc_point

Returns:

MCP_Geometric

property mcp_cost

Tie line costs array with barrier costs applied for MCP analysis

Returns:

ndarray

property row

Row index inside clipped array

Returns:

int

property row_offset

Offset to apply to row indices to move into clipped array

Returns:

int