reVX.least_cost_xmission.least_cost_xmission.LeastCostXmission

class LeastCostXmission(cost_fpath, features_fpath, resolution=128, xmission_config=None, min_line_length=0)[source]

Bases: LeastCostPaths

Compute Least Cost tie-line paths and full transmission cap cost for all possible connections to all supply curve points

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

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

  • min_line_length (int | float, optional) – Minimum line length in km, by default 0.

Methods

process_least_cost_paths(capacity_class[, ...])

Find Least Cost Paths between all pairs of provided features for the given tie-line capacity class

process_sc_points(capacity_class[, ...])

Compute Least Cost Transmission for desired sc_points

run(cost_fpath, features_fpath, capacity_class)

Find Least Cost Transmission connections between desired sc_points to given transmission features for desired capacity class

Attributes

REQUIRED_LAYERS

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).

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).

features

Table of features to compute paths for

sc_points

Table of supply curve points

sink_coords

Inf sink coordinates (row, col)

sink_tree

cKDTree for infinite sinks

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).

sub_lines_mapping

Series mapping substations to the transmission lines connected to each substation

property sc_points

Table of supply curve points

Returns:

gpd.GeoDataFrame

property features

Table of features to compute paths for

Returns:

pandas.DataFrame

property sub_lines_mapping

Series mapping substations to the transmission lines connected to each substation

Returns:

pandas.Series

property sink_coords

Inf sink coordinates (row, col)

Returns:

ndarray

property sink_tree

cKDTree for infinite sinks

Returns:

cKDTree

process_sc_points(capacity_class, sc_point_gids=None, nn_sinks=2, clipping_buffer=1.05, barrier_mult=100, max_workers=None, save_paths=False, radius=None, expand_radius=True, mp_delay=3, simplify_geo=None)[source]

Compute Least Cost Transmission for desired sc_points

Parameters:
  • capacity_class (str | int) – Capacity class of transmission features to connect supply curve points to

  • sc_point_gids (list, optional) – List of sc_point_gids to connect to, by default connect to all

  • nn_sinks (int, optional) – Number of nearest neighbor sinks to use for clipping radius calculation, by default 2

  • clipping_buffer (float, optional) – Buffer to expand clipping radius by, by default 1.05

  • barrier_mult (int, optional) – Transmission barrier multiplier, used when computing the least cost tie-line path, by default 100

  • 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 return least cost paths as a multi-line geometry, by default False

  • radius (None | int, optional) – Force clipping radius. Trasmission features beyond this radius will not be considered for connection with supply curve point. If None, no radius is forced, and connections to all available transmission features are computed. By default, None.

  • expand_radius (bool, optional) – Option to expand radius to include at least one connection feature. Has no effect if radius=None. By default, True.

  • mp_delay (float, optional) – Delay in seconds between starting multi-process workers. Useful for reducing memory spike at working startup.

  • simplify_geo (float | None, optional) – If float, simplify geometries using this value

Returns:

least_costs (pandas.DataFrame | gpd.GeoDataFrame) – Least cost connections between all supply curve points and the transmission features with the given capacity class that are within “nn_sink” nearest infinite sinks

classmethod run(cost_fpath, features_fpath, capacity_class, resolution=128, xmission_config=None, min_line_length=0, sc_point_gids=None, nn_sinks=2, clipping_buffer=1.05, barrier_mult=100, max_workers=None, save_paths=False, radius=None, expand_radius=True, simplify_geo=None)[source]

Find Least Cost Transmission connections between desired sc_points to given transmission features for desired 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

  • capacity_class (str | int) – Capacity class of transmission features to connect supply curve points to

  • resolution (int, optional) – SC point resolution, by default 128

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

  • min_line_length (int | float, optional) – Minimum line length in km, by default 0.

  • sc_point_gids (list, optional) – List of sc_point_gids to connect to, by default None

  • nn_sinks (int, optional) – Number of nearest neighbor sinks to use for clipping radius calculation, by default 2

  • clipping_buffer (float, optional) – Buffer to expand clipping radius by, by default 1.05

  • barrier_mult (int, optional) – Transmission barrier multiplier, used when computing the least cost tie-line path, by default 100

  • 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 return least costs path as a multi-line geometry, by default False

  • radius (None | int, optional) – Force clipping radius. Transmission features beyond this radius wil not be considered for connection with supply curve point. If None, no radius is forced, and connections to all available transmission features are computed. By default, None.

  • expand_radius (bool, optional) – Option to expand radius to include at least one connection feature. Has no effect if radius=None. By default, True.

  • simplify_geo (float | None, optional) – If float, simplify geometries using this value

Returns:

least_costs (pandas.DataFrame | gpd.DataFrame) – Least cost connections between all supply curve points and the transmission features with the given capacity class that are within “nn_sink” nearest infinite sinks

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(capacity_class, barrier_mult=100, indices=None, max_workers=None, save_paths=False)

Find Least Cost Paths between all pairs of provided features for the given tie-line capacity class

Parameters:
  • capacity_class (str | int) – Capacity class of transmission features to connect supply curve points to

  • barrier_mult (int, optional) – Transmission barrier multiplier, used when computing the least cost tie-line path, by default 100

  • 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

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

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