allagash.coverage module

Coverage

class allagash.coverage.Coverage(dataframe, demand_col=None, demand_name='demand', supply_name=None, coverage_type='binary')

An object that stores the relationship between a set of demand locations and a set of supply locations. Use this initializer if the coverage matrix has already been created, otherwise this can be created from two geodataframes using the from_geodataframes() or from_spatially_enabled_dataframes() factory methods.

Coverage.from_geodataframes(df1, df2, "Demand_Id", "Supply_Id")
Parameters:
  • dataframe (DataFrame) – A dataframe containing a matrix of demand (rows) and supply (columns). An additional column containing the demand values can optionally be provided.

  • demand_col (str) – (optional) The name of the column storing the demand value.

  • demand_name (str) – (optional) The name of the demand to use. If not supplied, ‘demand’ is used’.

  • supply_name (str) – (optional) The name of the supply to use. If not supplied, a random name is generated.

  • coverage_type (str) – (optional) The type of coverage this represents. If not supplied, the default is “binary”. Options are “binary” and “partial”.

property coverage_type
Returns:

The type of coverage

Return type:

str

property demand_col
Returns:

The name of the demand column in the underlying dataframe

Return type:

str or None

property demand_name
Returns:

The name of the demand

Return type:

str

property df
Returns:

The geodataframe the dataset is based on

Return type:

GeoDataFrame

classmethod from_geodataframes(demand_df, supply_df, demand_id_col, supply_id_col, demand_name='demand', supply_name=None, demand_col=None, coverage_type='binary')

Creates a new Coverage from two GeoDataFrames representing the demand and supply locations. The coverage is determined by intersecting the two dataframes.

Parameters:
  • demand_df (GeoDataFrame) – The GeoDataFrame containing the demand locations

  • supply_df (GeoDataFrame) – The GeoDataFrame containing the supply locations

  • demand_id_col (str) – The name of the column that has unique identifiers for the demand locations

  • supply_id_col (str) – The name of the column that has unique identifiers for the supply locations

  • demand_name (str) – (optional) The name of the demand to use. If not supplied, ‘demand’ is used.

  • supply_name (str) – (optional) The name of the supply to use. If not supplied, a random name is generated.

  • demand_col (str) – (optional) The name of the column that stores the amount of demand for the demand locations. Required if generating partial coverage.

  • coverage_type (str) – (optional) The type of coverage this represents. If not supplied, the default is “binary”. Options are “binary” and “partial”.

Returns:

The coverage

Return type:

Coverage

classmethod from_spatially_enabled_dataframes(demand_df, supply_df, demand_id_col, supply_id_col, demand_name='demand', supply_name=None, demand_col=None, coverage_type='binary', demand_geometry_col='SHAPE', supply_geometry_col='SHAPE')

Creates a new Coverage from two spatially enabled (arcgis) dataframes representing the demand and supply locations. The coverage is determined by intersecting the two dataframes.

Parameters:
  • demand_df (DataFrame) – The spatially enabled dataframe containing the demand locations

  • supply_df (DataFrame) – The spatially enavled dataframe containing the supply locations

  • demand_id_col (str) – The name of the column that has unique identifiers for the demand locations

  • supply_id_col (str) – The name of the column that has unique identifiers for the supply locations

  • demand_name (str) – (optional) The name of the demand to use. If not supplied, ‘demand’ is used’.

  • supply_name (str) – (optional) The name of the supply to use. If not supplied, a random name is generated.

  • demand_col (str) – (optional) The name of the column that stores the amount of demand for the demand locations. Required if generating partial coverage.

  • coverage_type (str) – (optional) The type of coverage this represents. If not supplied, the default is “binary”. Options are “binary” and “partial”.

  • demand_geometry_col (str) – (optional) The name of the field storing the geometry in the demand dataframe. If not supplied, the default is “SHAPE”.

  • supply_geometry_col (str) – (optional) The name of the field storing the geometry in the supply dataframe. If not supplied, the default is “SHAPE”.

Returns:

The coverage

Return type:

Coverage

property supply_name
Returns:

The name of the supply

Return type:

str