Generation and distribution factors

ultimodel.AttractionFactors.AttractionIndex(taz, taz_geo='geometry', taz_id='nuts_id')

Calculate population and industrial areas per TAZ, transform to attraction index

Parameters:
  • taz (gpd.GeoDataFrame) –

    GeoDataFrame with TAZ

  • taz_geo (str, default: 'geometry' ) –

    column name of geometry of taz

  • taz_id (str, default: 'nuts_id' ) –

    column name of id column in taz

population_from_point(pop_nodes, pop_val='VALUE')

Aggregate population per TAZ based on point layer with population density

--> result: self.taz as GeoDataFrame is updated with total population per cell

Parameters:
  • pop_nodes (gpd.GeoDataFrame) –

    GeoDataFrame with population density (points)

  • pop_val (str, default: 'VALUE' ) –

    name of column with population density in pop_nodes

Returns:
  • None

industry_attributes_from_osm(return_taz=False)

Extract the number and aggregated area of polygons with landuse=industrial in OSM per TAZ

Creates new columns in self.taz: - ind_area_count | number of industrial sites - ind_area_sum | aggregated area of industrial sites

TAZ with new industry column can be returned by setting return_taz=True

Parameters:
  • return_taz (bool, default: False ) –

    if True, return a GeoDataFrame

Returns:
  • gpd.GeoDataFrame

    TAZ with industrial site count (ind_area_count) and area (ind_area_sum)

industry_attributes_from_gdf(industry_gdf, return_taz=False)

Aggregate total area and count of industrial sites per TAZ based on a GeoDataFrame with industrial areas

--> result: self.taz as GeoDataFrame is updated with industrial area data per cell

Creates new columns in self.taz: - ind_area_count | number of industrial sites - ind_area_sum | aggregated area of industrial sites

Parameters:
  • industry_gdf (gpd.GeoDataFrame) –

    GeoDataFrame with industry areas (Polygons)

  • return_taz (bool, default: False ) –

    if True, return a GeoDataFrame

Returns:
  • gpd.GeoDataFrame

    TAZ with industrial site count (ind_area_count) and area (ind_area_sum)

attraction_index(scope=None, taz_cn='cntr_code', alpha=1.0)

Create attraction index with Cobb-Douglas transformation

Parameters:
  • scope (str, default: None ) –

    either look at all TAZ (None) or single country (str of ISO-code)

  • taz_cn (str, default: 'cntr_code' ) –

    column name for country identifier in self.taz

  • alpha (float, default: 1.0 ) –

    alpha parameter for Cobb Douglas formula

Returns:
  • GeoDataFrame with taz in scope and attraction index for scope

ultimodel.AttractionFactors.BorderCrossingAtts(taz, taz_cn='cntr_code', taz_geo='geometry')

Calculate country attributes like number of border crossing streets, neighboring countries that define the character of border-crossing road traffic

Parameters:
  • taz (gpd.GeoDataFrame) –

    GeoDataFrame with TAZ

  • taz_cn (str, default: 'cntr_code' ) –

    column name of country in TAZ

  • taz_geo (str, default: 'geometry' ) –

    column name of geometry in TAZ

get_borderbuffer(buffer=5000)

Create GeoDataFrame with borders, using a defined buffer around these borders (i.e. with a 5000m buffer, there will be Polygons along borders with a width of 5000m)

Parameters:
  • buffer (float, default: 5000 ) –

    total buffer width in m, default 5000m

Returns:
  • GeoDataFrame with buffer polygons around borders

shared_borders(inplace=False)

Determine the share of land borders of total country border. Islands would have a share of 0, while countries without a cost would land at 1.

--> result: border shares are merged to self.country_layer

Parameters:
  • inplace (bool, default: False ) –

    return DataFrame; if True, DataFrame is not returned

Returns:
  • pd.DataFrame with border length and share per country / if inplace=True return None

border_streets(net, net_type='type', type_filter=None, inplace=None)

Count the number of border crossing streets per country

--> result: number of border crossings is merged to self.country_layer

Parameters:
  • net (gpd.GeoDataFrame) –

    GeoDataFrame with international road network

  • net_type (str, default: 'type' ) –

    name of column specifiying road type in net

  • type_filter (list, default: None ) –

    list of road types to filter for border crossing roads; default None, meaning types [1,2]

  • inplace (bool, default: None ) –

    return DataFrame; if True, DataFrame is not returned

Returns:
  • pd.DataFrame with number of border crossing streets per country / if inplace=True return None

count_neighbors(inplace=False)

Determine the number of direct neighbor countries (shared border)

--> result: number of neighbors is merged to self.country_layer

Parameters:
  • inplace (bool, default: False ) –

    return DataFrame; if True, DataFrame is not returned

Returns:
  • pd.DataFrame with number of neighbor countries per country / if inplace=True return None

pop_area(pop_values=None, pop_cn='country', taz_pop='population', inplace=False)

Determine total population and area im km² per country. Population can be determined by aggregating population per taz or with and external input DataFrame

--> result: population and area are merged to self.country_layer

Parameters:
  • pop_values (pd.DataFrame, default: None ) –

    pd.DataFrame with population per country; if None, population will be aggregated from taz attributes, default None

  • pop_cn (str, default: 'country' ) –

    name of column with country name in pop_values

  • taz_pop (str, default: 'population' ) –

    name of column with population in self.taz

  • inplace (bool, default: False ) –

    return GeoDataFrame with border shares; if True, DataFrame is not returned

Returns:
  • GeoDataFrame with countries and their population and area / if inplace=True return None

ultimodel.Matrices.Matrix(conn, zone_col='zone', id_col='con_id', weight_col='weight', x_='x', y_='y', conn_geo='geometry')

Create cost matrices from OSRM

Parameters:
  • conn (pd.DataFrame | gpd.GeoDataFrame) –

    DF / GDF of connector nodes; if DF, include x and y coordinates

  • zone_col (str, default: 'zone' ) –

    name of column with zone ID in conn

  • id_col (str, default: 'con_id' ) –

    name of connector ID column in conn

  • weight_col (str, default: 'weight' ) –

    name of weight column in conn

  • x_ (str, default: 'x' ) –

    name of x coordinate column in conn (if conn does not have a geometry column)

  • y_ (str, default: 'y' ) –

    name of y coordinate column in conn (if conn does not have a geometry column)

  • conn_geo (str, default: 'geometry' ) –

    name of geometry column in conn (if conn is a GeoDataFrame)

osrm_request_nodes(save_np=None)

OSRM Request: extract travel durations and distances from OSM routing

--> result: self.all_mtx as updated npy array with distances and durations between connector nodes

Parameters:
  • save_np (str, default: None ) –

    default None; filename for saving result matrux, if given, a npy-file of self.all_mtx is saved, updated with the results per iteration

Returns:
  • None

transform_to_taz()

Use connectors weights to generate the mean travel time and distances per taz, based on matrices between connectors

Returns:
  • np.array, pd.DataFrame

    array with weighted mean travel times and distances and DataFrame with zone IDs and index numbers (index in matrix)