OpenStreetGraphBuilder#

class shift.OpenStreetGraphBuilder(groups: list[~shift.data_model.GroupModel], source_location: ~shift.data_model.GeoLocation, buffer: ~infrasys.quantities.Distance = <Quantity(20, 'meter')>)#

Abstract class interface for building distribution graph using openstreet data.

Parameters:
  • groups (list[GroupModel]) – List of groups for building a openstreet network.

  • source_location (GeoLocation) – Power source location.

  • buffer (Distance, optional) – Buffer to be applied in a bounding polygon formed by points for searching road network. Defaults to 20m.

Examples

>>> from shift import get_parcels, get_kmeans_clusters
>>> points = get_parcels("Fort Worth, Texas", Distance(100, "m"))
>>> groups = get_kmeans_clusters(5, [el.geometry[0] if isinstance(el.geometry, list)
    else el.geometry for el in points])
>>> builder = OpenStreetGraphBuilder(groups, GeoLocation(-97.3308, 32.7555))
>>> graph = builder.get_distribution_graph()

Constructor for the class.

Parameters:
  • groups (list[GroupModel]) – List of groups for building a openstreet network.

  • source_location (GeoLocation) – Power source location.

  • buffer (Distance, optional) – Buffer to be applied in a bounding polygon formed by points for searching road network. Defaults to 20m.

Methods#

OpenStreetGraphBuilder.__init__(groups, ...)

Constructor for the class.

OpenStreetGraphBuilder.get_distribution_graph()

Method to return distribution graph.