vtra.flow_mapping package

Flow mapping

Submodules

vtra.flow_mapping.national_modes_flow_paths module

Map flows on national networks

Purpose

Mapping the OD node level matrix values to network paths

For all transport modes at national scale: [‘road’, ‘rail’, ‘air’, ‘inland’, ‘coastal’]

The code estimates 2 values - A MIN and a MAX value of flows between each selected OD node pair
  • Based on MIN-MAX generalised costs estimates

Input data requirements

  1. Correct paths to all files and correct input parameters
  2. Excel file with mode sheets containing network graph structure and attributes
    • edge_id - String Edge ID
    • from_node - String node ID that should be present in node_id column
    • to_node - String node ID that should be present in node_id column
    • length - Float length of edge in km
    • min_time - Float minimum time of travel in hours on edge
    • max_time - Float maximum time of travel in hours on edge
    • min_time_cost - Float minimum cost of time in USD on edge
    • max_time_cost - Float maximum cost of time in USD on edge
    • min_tariff_cost - Float minimum tariff cost in USD on edge
    • max_tariff_cost - Float maximum tariff cost in USD on edge
  3. Edge shapefiles for all national-scale networks with attributes:
    • edge_id - String Edge ID
    • geometry - Shapely LineString geometry of edges
  4. Excel file with mode sheets containing node-level OD values with attributes:
    • origin - String node ID of Origin
    • destination - String node ID of Destination
    • min_tons - Float values of minimum daily OD in tons
    • max_tons - Float values of maximum daily OD in tons
    • Names of the industry columns specified in the inputs

Results

  1. Excel sheets with results of flow mapping based on MIN-MAX generalised costs estimates:
    • origin - String node ID of Origin
    • destination - String node ID of Destination
    • o_region - String name of Province of Origin node ID
    • d_region - String name of Province of Destination node ID
    • min_edge_path - List of string of edge ID’s for paths with minimum generalised cost flows
    • max_edge_path - List of string of edge ID’s for paths with maximum generalised cost flows
    • min_distance - Float values of estimated distance for paths with minimum generalised cost flows
    • max_distance - Float values of estimated distance for paths with maximum generalised cost flows
    • min_time - Float values of estimated time for paths with minimum generalised cost flows
    • max_time - Float values of estimated time for paths with maximum generalised cost flows
    • min_gcost - Float values of estimated generalised cost for paths with minimum generalised cost flows
    • max_gcost - Float values of estimated generalised cost for paths with maximum generalised cost flows
    • min_vehicle_nums - Float values of estimated vehicle numbers for paths with minimum generalised cost flows
    • max_vehicle_nums - Float values of estimated vehicle numbers for paths with maximum generalised cost flows
    • industry_columns - All daily tonnages of industry columns given in the OD matrix data
  2. Shapefiles
    • edge_id - String/Integer/Float Edge ID
    • geometry - Shapely LineString geomtry of edges
    • min_{industry} - Float values of estimated minimum daily industries/commodities/total volumes in tons on edges
    • max_{industry} - Float values of estimated maximum daily industries/commodities/total volumes in tons on edges

References

  1. Pant, R., Koks, E.E., Russell, T., Schoenmakers, R. & Hall, J.W. (2018). Analysis and development of model for addressing climate change/disaster risks in multi-modal transport networks in Vietnam. Final Report, Oxford Infrastructure Analytics Ltd., Oxford, UK.
  2. All input data folders and files referred to in the code below.
main()[source]

Estimate flows

  1. Specify the paths from where you want to read and write:
    • Input data
    • Intermediate calcuations data
    • Output results
  2. Supply input data and parameters
    • Names of modes: List of strings
    • Unit weight of vehicle assumed for each mode: List of float types
    • Names of all industry sector and crops in VITRANSS2 and IFPRI datasets: List of string types
    • Names of commodity/industry columns for which min-max tonnage column names already exist: List of string types
    • Percentage of OD flow we want to send along path: FLoat type
  3. Give the paths to the input data files:
    • Network edges Excel file
    • OD flows Excel file
    • Costs of modes Excel file
    • Road properties Excel file
  4. Specify the output files and paths to be created
network_od_paths_assembly_national(points_dataframe, graph, vehicle_wt, transport_mode, excel_writer='')[source]

Assemble estimates of OD paths, distances, times, costs and tonnages on networks

Parameters:
  • points_dataframe (pandas.DataFrame) – OD nodes and their tonnages
  • graph – igraph network structure
  • vehicle_wt (float) – unit weight of vehicle
  • transport_mode (str) – name of modes
  • excel_writer – Name of the excel writer to save Pandas dataframe to Excel file
Returns:

save_paths_df

  • origin - String node ID of Origin
  • destination - String node ID of Destination
  • min_edge_path - List of string of edge ID’s for paths with minimum generalised cost flows
  • max_edge_path - List of string of edge ID’s for paths with maximum generalised cost flows
  • min_distance - Float values of estimated distance for paths with minimum generalised cost flows
  • max_distance - Float values of estimated distance for paths with maximum generalised cost flows
  • min_time - Float values of estimated time for paths with minimum generalised cost flows
  • max_time - Float values of estimated time for paths with maximum generalised cost flows
  • min_gcost - Float values of estimated generalised cost for paths with minimum generalised cost flows
  • max_gcost - Float values of estimated generalised cost for paths with maximum generalised cost flows
  • min_vehicle_nums - Float values of estimated vehicle numbers for paths with minimum generalised cost flows
  • max_vehicle_nums - Float values of estimated vehicle numbers for paths with maximum generalised cost flows
  • industry_columns - All tonnages of industry columns given in the OD matrix data

Return type:

pandas.DataFrame

vtra.flow_mapping.province_roads_access_flow_paths module

Map flows on provincial networks

Purpose

Mapping the commune access OD node level matrix values to road network paths in Provinces

For all roads in the Provinces: [‘Lao Cai’, ‘Binh Dinh’, ‘Thanh Hoa’]

The code estimates 2 values - A MIN and a MAX value of flows between each selected OD node pair
  • Based on MIN-MAX generalised costs estimates

Input data requirements

  1. Correct paths to all files and correct input parameters
  2. Excel file with mode sheets containing network graph structure and attributes
    • edge_id - String Edge ID
    • from_node - String node ID that should be present in node_id column
    • to_node - String node ID that should be present in node_id column
    • length - Float length of edge in km
    • min_time - Float minimum time of travel in hours on edge
    • max_time - Float maximum time of travel in hours on edge
    • min_time_cost - Float minimum cost of time in USD on edge
    • max_time_cost - Float maximum cost of time in USD on edge
    • min_tariff_cost - Float minimum tariff cost in USD on edge
    • max_tariff_cost - Float maximum tariff cost in USD on edge
  3. Edge shapefiles for all national-scale networks with attributes:
    • edge_id - String Edge ID
    • geometry - Shapely LineString geometry of edges
  4. Excel file with mode sheets containing node-level OD values with attributes:
    • origin - String node ID of Origin
    • destination - String node ID of Destination
    • min_netrev - Float values of miniimum daily OD Net Revenue in USD
    • max_netrev - Float values of maximum daily OD Net Revenue in USD
    • min_tons - Float values of minimum daily OD in tons
    • max_tons - Float values of maximum daily OD in tons

Results

  1. Excel sheets with results of flow mapping based on MIN-MAX generalised costs estimates:
    • origin - String node ID of Origin
    • destination - String node ID of Destination
    • min_edge_path - List of string of edge ID’s for paths with minimum generalised cost flows
    • max_edge_path - List of string of edge ID’s for paths with maximum generalised cost flows
    • min_netrev - Float values of estimated daily Net Revenue for paths with minimum generalised cost flows
    • max_netrev - Float values of estimated daily Net Revenue for paths with maximum generalised cost flows
    • min_croptons - Float values of estimated daily crop tonnage for paths with minimum generalised cost flows
    • max_croptons - Float values of estimated daily crop tonnage for paths with maximum generalised cost flows
    • min_distance - Float values of estimated distance for paths with minimum generalised cost flows
    • max_distance - Float values of estimated distance for paths with maximum generalised cost flows
    • min_time - Float values of estimated time for paths with minimum generalised cost flows
    • max_time - Float values of estimated time for paths with maximum generalised cost flows
    • min_gcost - Float values of estimated generalised cost for paths with minimum generalised cost flows
    • max_gcost - Float values of estimated generalised cost for paths with maximum generalised cost flows
    • min_vehicle_nums - Float values of estimated vehicle numbers for paths with minimum generalised cost flows
    • max_vehicle_nums - Float values of estimated vehicle numbers for paths with maximum generalised cost flows
  2. Shapefiles with all flows on edges mapping based on MIN-MAX generalised costs estimates:
    • edge_id - String/Integer/Float Edge ID
    • geometry - Shapely LineString geomtry of edges
    • min_netrev - Float values of estimated daily Net Revenue in USD on edges
    • max_netrev - Float values of estimated daily Net Revenue in USD on edges
    • min_tons - Float values of estimated daily crops in tons on edges
    • max_tons - Float values of estimated daily crops in tons on edges

References

  1. Pant, R., Koks, E.E., Russell, T., Schoenmakers, R. & Hall, J.W. (2018). Analysis and development of model for addressing climate change/disaster risks in multi-modal transport networks in Vietnam. Final Report, Oxford Infrastructure Analytics Ltd., Oxford, UK.
  2. All input data folders and files referred to in the code below.
main()[source]

Map flows to networks

  1. Specify the paths from where you want to read and write:
    • Input data
    • Intermediate calcuations data
    • Output results
  2. Supply input data and parameters
    • Names of the three Provinces: List of string types
    • Assumed terrains of the provinces: List of string types
    • Assumed unit weights of trucks: List of float types
  3. Give the paths to the input data files:
    • Network edges EXcel File
    • OD flows Excel file
    • Road properties Excel file
  4. Specify the output files and paths to be created
network_od_paths_assembly_provincial(points_dataframe, graph, vehicle_wt, region_name, excel_writer='')[source]

Assemble estimates of OD paths, distances, times, costs and tonnages on networks

Parameters:
  • points_dataframe (pandas.DataFrame) – OD nodes and their tonnages
  • graph – igraph network structure
  • vehicle_wt (float) – unit weight of vehicle
  • region_name (str) – name of Province
  • excel_writer – Name of the excel writer to save Pandas dataframe to Excel file
Returns:

save_paths_df

  • origin - String node ID of Origin
  • destination - String node ID of Destination
  • min_edge_path - List of string of edge ID’s for paths with minimum generalised cost flows
  • max_edge_path - List of string of edge ID’s for paths with maximum generalised cost flows
  • min_netrev - Float values of estimated netrevenue for paths with minimum generalised cost flows
  • max_netrev - Float values of estimated netrevenue for paths with maximum generalised cost flows
  • min_croptons - Float values of estimated crop tons for paths with minimum generalised cost flows
  • max_croptons - Float values of estimated crop tons for paths with maximum generalised cost flows
  • min_distance - Float values of estimated distance for paths with minimum generalised cost flows
  • max_distance - Float values of estimated distance for paths with maximum generalised cost flows
  • min_time - Float values of estimated time for paths with minimum generalised cost flows
  • max_time - Float values of estimated time for paths with maximum generalised cost flows
  • min_gcost - Float values of estimated generalised cost for paths with minimum generalised cost flows
  • max_gcost - Float values of estimated generalised cost for paths with maximum generalised cost flows
  • min_vehicle_nums - Float values of estimated vehicle numbers for paths with minimum generalised cost flows
  • max_vehicle_nums - Float values of estimated vehicle numbers for paths with maximum generalised cost flows

Return type:

pandas.DataFrame