lasso.ModelRoadwayNetwork

class lasso.ModelRoadwayNetwork(nodes, links, shapes, parameters={})[source]

Bases: network_wrangler.roadwaynetwork.RoadwayNetwork

Subclass of network_wrangler class RoadwayNetwork

A representation of the physical roadway network and its properties.

__init__(nodes, links, shapes, parameters={})[source]

Constructor

Parameters
  • nodes – geodataframe of nodes

  • links – dataframe of links

  • shapes – geodataframe of shapes

  • parameters – dictionary of parameter settings (see Parameters class) or an instance of Parameters. If not specified, will use default parameters.

Methods

__init__(nodes, links, shapes[, parameters])

Constructor

add_counts([network_variable, …])

Adds count variable.

add_new_roadway_feature_change(links, nodes)

add the new roadway features defined in the project card.

add_variable_using_shst_reference([…])

Join network links with source data, via SHST API node match result.

addition_map(links, nodes)

Shows which links and nodes are added to the roadway network

apply(project_card_dictionary)

Wrapper method to apply a project to a roadway network.

apply_managed_lane_feature_change(link_idx, …)

Apply the managed lane feature changes to the roadway network

apply_python_calculation(pycode[, in_place])

Changes roadway network object by executing pycode.

apply_roadway_feature_change(link_idx, …)

Changes the roadway attributes for the selected features based on the project card information passed

assess_connectivity([mode, …])

Returns a network graph and list of disconnected subgraphs as described by a list of their member nodes.

build_selection_key(selection_dict)

Selections are stored by a key combining the query and the A and B ids.

calculate_area_type([area_type_shape, …])

Calculates area type variable.

calculate_assign_group_and_roadway_class([…])

Calculates assignment group and roadway class variables.

calculate_centroidconnect([…])

Calculates centroid connector variable.

calculate_county([county_shape, …])

Calculates county variable.

calculate_distance([network_variable, …])

calculate link distance in miles

calculate_hov([network_variable, …])

Calculates hov variable.

calculate_mpo([county_network_variable, …])

Calculates mpo variable.

convert_int([int_col_names])

Convert integer columns

create_ML_variable([network_variable, overwrite])

Created ML lanes placeholder for project to write out ML changes

create_calculated_variables()

Creates calculated roadway variables.

create_dummy_connector_links(ml_df)

create dummy connector links between the general purpose and managed lanes

create_hov_corridor_variable([…])

Created hov corridor placeholder for project to write out corridor changes

create_managed_lane_network([in_place])

Create a roadway network with managed lanes links separated out.

create_managed_variable([network_variable, …])

Created placeholder for project to write out managed

dataframe_to_fixed_width(df)

Convert dataframe to fixed width format, geometry column will not be transformed.

delete_roadway_feature_change(links, nodes)

delete the roadway features defined in the project card.

deletion_map(links, nodes)

Shows which links and nodes are deleted from the roadway network

fill_na()

Fill na values from create_managed_lane_network()

from_RoadwayNetwork(roadway_network_object)

RoadwayNetwork to ModelRoadwayNetwork

get_attribute(links_df, join_key, …)

Gets attribute from source data using SHST match result.

get_managed_lane_node_ids(nodes_list)

get_modal_graph(links_df, nodes_df[, mode])

Determines if the network graph is “strongly” connected A graph is strongly connected if each vertex is reachable from every other vertex.

get_modal_links_nodes(links_df, nodes_df[, …])

Returns nodes and link dataframes for specific mode.

get_property_by_time_period_and_group(property)

Return a series for the properties with a specific group or time period.

is_network_connected([mode, links_df, nodes_df])

Determines if the network graph is “strongly” connected A graph is strongly connected if each vertex is reachable from every other vertex.

network_connection_plot(G, …)

Plot a graph to check for network connection.

orig_dest_nodes_foreign_key(selection[, …])

Returns the foreign key id (whatever is used in the u and v variables in the links file) for the AB nodes as a tuple.

ox_graph(nodes_df, links_df)

create an osmnx-flavored network graph

read(link_file, node_file, shape_file[, …])

Reads in links and nodes network standard.

read_match_result(path)

Reads the shst geojson match returns.

rename_variables_for_dbf(input_df[, …])

Rename attributes for DBF/SHP, make sure length within 10 chars.

roadway_net_to_gdf(roadway_net)

Turn the roadway network into a GeoDataFrame :param roadway_net: the roadway network to export

roadway_standard_to_met_council_network([…])

Rename and format roadway attributes to be consistent with what metcouncil’s model is expecting.

select_roadway_features(selection[, …])

Selects roadway features that satisfy selection criteria

selection_has_unique_link_id(selection_dict)

param selection_dictionary

Dictionary representation of selection

selection_map(selected_link_idx[, A, B, …])

Shows which links are selected for roadway property change or parallel managed lanes category of roadway projects.

split_properties_by_time_period_and_category([…])

Splits properties by time period, assuming a variable structure of

validate_link_schema(link_file[, …])

Validate roadway network data link schema and output a boolean

validate_node_schema(node_file[, …])

Validate roadway network data node schema and output a boolean

validate_object_types(nodes, links, shapes)

Determines if the roadway network is being built with the right object types.

validate_properties(properties[, …])

If there are change or existing commands, make sure that that property exists in the network.

validate_selection(selection)

Evaluate whetther the selection dictionary contains the minimum required values.

validate_shape_schema(shape_file[, …])

Validate roadway network data shape schema and output a boolean

validate_uniqueness()

Confirms that the unique identifiers are met.

write([path, filename])

Writes a network in the roadway network standard

write_roadway_as_fixedwidth([…])

Writes out fixed width file.

write_roadway_as_shp([…])

Write out dbf/shp for cube.

Attributes

CALCULATED_VALUES

CRS

KEEP_SAME_ATTRIBUTES_ML_AND_GP

LINK_FOREIGN_KEY

MANAGED_LANES_LINK_ID_SCALAR

MANAGED_LANES_NODE_ID_SCALAR

MANAGED_LANES_REQUIRED_ATTRIBUTES

MANAGED_LANES_SCALAR

MAX_SEARCH_BREADTH

MODES_TO_NETWORK_LINK_VARIABLES

MODES_TO_NETWORK_NODE_VARIABLES

NODE_FOREIGN_KEY

SEARCH_BREADTH

SELECTION_REQUIRES

SP_WEIGHT_FACTOR

UNIQUE_LINK_KEY

UNIQUE_MODEL_LINK_IDENTIFIERS

UNIQUE_NODE_IDENTIFIERS

UNIQUE_NODE_KEY

UNIQUE_SHAPE_KEY

add_counts(network_variable='AADT', mndot_count_shst_data=None, widot_count_shst_data=None, mndot_count_variable_shp=None, widot_count_variable_shp=None)[source]

Adds count variable.

join the network with count node data, via SHST API node match result

Parameters
  • network_variable (str) – Name of the variable that should be written to. Default to “AADT”.

  • mndot_count_shst_data (str) – File path to MNDOT count location SHST API node match result.

  • widot_count_shst_data (str) – File path to WIDOT count location SHST API node match result.

  • mndot_count_variable_shp (str) – File path to MNDOT count location geodatabase.

  • widot_count_variable_shp (str) – File path to WIDOT count location geodatabase.

Returns

None

add_new_roadway_feature_change(links, nodes)

add the new roadway features defined in the project card. new shapes are also added for the new roadway links.

Parameters
  • links – list of dictionaries

  • nodes – list of dictionaries

returns: None

Return type

None

add_variable_using_shst_reference(var_shst_csvdata=None, shst_csv_variable=None, network_variable=None, network_var_type=<class 'int'>, overwrite=False)[source]

Join network links with source data, via SHST API node match result.

Parameters
  • var_shst_csvdata (str) – File path to SHST API return.

  • shst_csv_variable (str) – Variable name in the source data.

  • network_variable (str) – Name of the variable that should be written to.

  • network_var_type – Variable type in the written network.

  • overwrite (bool) – True is overwriting existing variable. Default to False.

Returns

None

addition_map(links, nodes)

Shows which links and nodes are added to the roadway network

apply(project_card_dictionary)

Wrapper method to apply a project to a roadway network.

Parameters

project_card_dictionary – dict a dictionary of the project card object

apply_managed_lane_feature_change(link_idx, properties, in_place=True)

Apply the managed lane feature changes to the roadway network

Parameters
  • link_idx – list of lndices of all links to apply change to

  • properties – list of dictionarys roadway properties to change

  • in_place – boolean to indicate whether to update self or return a new roadway network object

Return type

Union(None, RoadwayNetwork)

apply_python_calculation(pycode, in_place=True)

Changes roadway network object by executing pycode.

Parameters
  • pycode – python code which changes values in the roadway network object

  • in_place – update self or return a new roadway network object

Return type

Union(None, RoadwayNetwork)

apply_roadway_feature_change(link_idx, properties, in_place=True)

Changes the roadway attributes for the selected features based on the project card information passed

Parameters
  • link_idx – list lndices of all links to apply change to

  • properties – list of dictionarys roadway properties to change

  • in_place – boolean update self or return a new roadway network object

Return type

Union(None, RoadwayNetwork)

assess_connectivity(mode='', ignore_end_nodes=True, links_df=None, nodes_df=None)

Returns a network graph and list of disconnected subgraphs as described by a list of their member nodes.

Parameters
  • mode – list of modes of the network, one of drive,`transit`, walk, bike

  • ignore_end_nodes – if True, ignores stray singleton nodes

  • links_df – if specified, will assess connectivity of this links list rather than self.links_df

  • nodes_df – if specified, will assess connectivity of this nodes list rather than self.nodes_df

Returns: Tuple of

Network Graph (osmnx flavored networkX DiGraph) List of disconnected subgraphs described by the list of their

member nodes (as described by their model_node_id)

build_selection_key(selection_dict)

Selections are stored by a key combining the query and the A and B ids. This method combines the two for you based on the selection dictionary.

Parameters

selection_dictonary – Selection Dictionary

Returns: Tuple serving as the selection key.

Return type

tuple

calculate_area_type(area_type_shape=None, area_type_shape_variable=None, network_variable='area_type', area_type_codes_dict=None, downtown_area_type_shape=None, downtown_area_type=None, overwrite=False)[source]

Calculates area type variable.

This uses the centroid of the geometry field to determine which area it should be labeled. This isn’t perfect, but it much quicker than other methods.

Parameters
  • area_type_shape (str) – The File path to area geodatabase.

  • area_type_shape_variable (str) – The variable name of area type in area geodadabase.

  • network_variable (str) – The variable name of area type in network standard. Default to “area_type”.

  • area_type_codes_dict – The dictionary to map input area_type_shape_variable to network_variable

  • downtown_area_type_shape – The file path to the downtown area type boundary.

  • downtown_area_type (int) – Integer value of downtown area type

  • overwrite (Bool) – True if overwriting existing county variable in network. Default to False.

Returns

None

calculate_assign_group_and_roadway_class(assign_group_variable_name='assign_group', road_class_variable_name='roadway_class', mrcc_roadway_class_shape=None, mrcc_shst_data=None, mrcc_roadway_class_variable_shp=None, mrcc_assgngrp_dict=None, widot_roadway_class_shape=None, widot_shst_data=None, widot_roadway_class_variable_shp=None, widot_assgngrp_dict=None, osm_assgngrp_dict=None, overwrite=False)[source]

Calculates assignment group and roadway class variables.

Assignment Group is used in MetCouncil’s traffic assignment to segment the volume/delay curves. Original source is from the MRCC data for the Minnesota: “route system” which is a roadway class For Wisconsin, it is from the Wisconsin DOT database, which has a variable called “roadway category”

There is a crosswalk between the MRCC Route System and Wisconsin DOT –> Met Council Assignment group

This method joins the network with mrcc and widot roadway data by shst js matcher returns

Parameters
  • assign_group_variable_name (str) – Name of the variable assignment group should be written to. Default to “assign_group”.

  • road_class_variable_name (str) – Name of the variable roadway class should be written to. Default to “roadway_class”.

  • mrcc_roadway_class_shape (str) – File path to the MRCC route system geodatabase.

  • mrcc_shst_data (str) – File path to the MRCC SHST match return.

  • mrcc_roadway_class_variable_shp (str) – Name of the variable where MRCC route system are stored.

  • mrcc_assgngrp_dict (dict) – Dictionary to map MRCC route system variable to assignment group.

  • widot_roadway_class_shape (str) – File path to the WIDOT roadway category geodatabase.

  • widot_shst_data (str) – File path to the WIDOT SHST match return.

  • widot_roadway_class_variable_shp (str) – Name of the variable where WIDOT roadway category are stored.

  • widot_assgngrp_dict (dict) – Dictionary to map WIDOT roadway category variable to assignment group.

  • osm_assgngrp_dict (dict) – Dictionary to map OSM roadway class to assignment group.

Returns

None

calculate_centroidconnect(network_variable='centroidconnect', highest_taz_number=None, as_integer=True, overwrite=False, lanes_variable='lanes', number_of_lanes=1)[source]

Calculates centroid connector variable.

Parameters
  • network_variable (str) – Variable that should be written to in the network. Default to “centroidconnect”

  • highest_taz_number (int) – the max TAZ number in the network.

  • as_integer (bool) – If True, will convert true/false to 1/0s. Default to True.

  • overwrite (Bool) – True if overwriting existing county variable in network. Default to False.

  • lanes_variable (str) – Variable that stores the number of lanes. Default to “lanes”.

  • number_of_lanes (int) – Number of lanes for centroid connectors. Default to 1.

Returns

None

calculate_county(county_shape=None, county_shape_variable=None, network_variable='county', county_codes_dict=None, overwrite=False)[source]

Calculates county variable.

This uses the centroid of the geometry field to determine which county it should be labeled. This isn’t perfect, but it much quicker than other methods.

Parameters
  • county_shape (str) – The File path to county geodatabase.

  • county_shape_variable (str) – The variable name of county in county geodadabase.

  • network_variable (str) – The variable name of county in network standard. Default to “county”.

  • overwrite (Bool) – True if overwriting existing county variable in network. Default to False.

Returns

None

calculate_distance(network_variable='distance', centroidconnect_only=True, overwrite=False)[source]

calculate link distance in miles

Parameters
  • centroidconnect_only (Bool) – True if calculating distance for centroidconnectors only. Default to True.

  • overwrite (Bool) – True if overwriting existing variable in network. Default to False.

Returns

None

calculate_hov(network_variable='HOV', as_integer=True, overwrite=False)[source]

Calculates hov variable.

Parameters
  • network_variable (str) – Variable that should be written to in the network. Default to “HOV”

  • as_integer (bool) – If True, will convert true/false to 1/0s. Defauly to True.

  • overwrite (Bool) – True if overwriting existing county variable in network. Default to False.

Returns

None

calculate_mpo(county_network_variable='county', network_variable='mpo', as_integer=True, mpo_counties=None, overwrite=False)[source]

Calculates mpo variable.

Parameters
  • county_variable (str) – Name of the variable where the county names are stored. Default to “county”.

  • network_variable (str) – Name of the variable that should be written to. Default to “mpo”.

  • as_integer (bool) – If true, will convert true/false to 1/0s.

  • mpo_counties (list) – List of county names that are within mpo region.

  • overwrite (Bool) – True if overwriting existing county variable in network. Default to False.

Returns

None

convert_int(int_col_names=[])[source]

Convert integer columns

create_ML_variable(network_variable='ML_lanes', overwrite=False)[source]

Created ML lanes placeholder for project to write out ML changes

ML lanes default to 0, ML info comes from cube LOG file and store in project cards

Parameters

overwrite (Bool) – True if overwriting existing variable in network. Default to False.

Returns

None

create_calculated_variables()[source]

Creates calculated roadway variables.

Parameters

None

create dummy connector links between the general purpose and managed lanes

Parameters
  • gp_df – GeoDataFrame dataframe of general purpose links (where managed lane also exists)

  • ml_df – GeoDataFrame dataframe of corresponding managed lane links

create_hov_corridor_variable(network_variable='segment_id', overwrite=False)[source]

Created hov corridor placeholder for project to write out corridor changes

hov corridor id default to 0, its info comes from cube LOG file and store in project cards

Parameters

overwrite (Bool) – True if overwriting existing variable in network. Default to False.

Returns

None

create_managed_lane_network(in_place=False)

Create a roadway network with managed lanes links separated out. Add new parallel managed lane links, access/egress links, and add shapes corresponding to the new links

Parameters

in_place – update self or return a new roadway network object

returns: A RoadwayNetwork instance

Return type

RoadwayNetwork

create_managed_variable(network_variable='managed', overwrite=False)[source]

Created placeholder for project to write out managed

managed default to 0, its info comes from cube LOG file and store in project cards

Parameters

overwrite (Bool) – True if overwriting existing variable in network. Default to False.

Returns

None

static dataframe_to_fixed_width(df)[source]

Convert dataframe to fixed width format, geometry column will not be transformed.

Parameters

df (pandas DataFrame) –

Returns

dataframe with fixed width for each column. dict: dictionary with columns names as keys, column width as values.

Return type

pandas dataframe

delete_roadway_feature_change(links, nodes, ignore_missing=True)

delete the roadway features defined in the project card. valid links and nodes defined in the project gets deleted and shapes corresponding to the deleted links are also deleted.

Parameters
  • links – dict list of dictionaries

  • nodes – dict list of dictionaries

  • ignore_missing – bool If True, will only warn about links/nodes that are missing from network but specified to “delete” in project card If False, will fail.

Return type

None

deletion_map(links, nodes)

Shows which links and nodes are deleted from the roadway network

fill_na()[source]

Fill na values from create_managed_lane_network()

static from_RoadwayNetwork(roadway_network_object, parameters={})[source]

RoadwayNetwork to ModelRoadwayNetwork

Parameters
  • roadway_network_object (RoadwayNetwork) –

  • parameters – dictionary of parameter settings (see Parameters class) or an instance of Parameters. If not specified, will use default parameters.

Returns

ModelRoadwayNetwork

static get_attribute(links_df, join_key, source_shst_ref_df, source_gdf, field_name)[source]

Gets attribute from source data using SHST match result.

Parameters
  • links_df (dataframe) – The network dataframe that new attribute should be written to.

  • join_key (str) – SHST ID variable name used to join source data with network dataframe.

  • source_shst_ref_df (str) – File path to source data SHST match result.

  • source_gdf (str) – File path to source data.

  • field_name (str) – Name of the attribute to get from source data.

Returns

None

static get_managed_lane_node_ids(nodes_list)
static get_modal_graph(links_df, nodes_df, mode=None)

Determines if the network graph is “strongly” connected A graph is strongly connected if each vertex is reachable from every other vertex.

Parameters
  • links_df – DataFrame of standard network links

  • nodes_df – DataFrame of standard network nodes

  • mode – mode of the network, one of drive,`transit`, walk, bike

Returns: networkx: osmnx: DiGraph of network

Returns nodes and link dataframes for specific mode.

Parameters
  • links_df – DataFrame of standard network links

  • nodes_df – DataFrame of standard network nodes

  • modes – list of the modes of the network to be kept, must be in drive,`transit`,`rail`,`bus`, walk, bike. For example, if bike and walk are selected, both bike and walk links will be kept.

Returns: tuple of DataFrames for links, nodes filtered by mode

links with walk access are not marked as having walk access Issue discussed in https://github.com/wsp-sag/network_wrangler/issues/145 modal_nodes_df = nodes_df[nodes_df[mode_node_variable] == 1]

get_property_by_time_period_and_group(property, time_period=None, category=None)

Return a series for the properties with a specific group or time period.

Parameters
  • property (str) – the variable that you want from network

  • time_period (list(str)) – the time period that you are querying for i.e. [‘16:00’, ‘19:00’]

  • category (str or list(str)(Optional)) –

    the group category i.e. “sov”

    or

    list of group categories in order of search, i.e. [“hov3”,”hov2”]

Returns

Return type

pandas series

is_network_connected(mode=None, links_df=None, nodes_df=None)

Determines if the network graph is “strongly” connected A graph is strongly connected if each vertex is reachable from every other vertex.

Parameters
  • mode – mode of the network, one of drive,`transit`, walk, bike

  • links_df – DataFrame of standard network links

  • nodes_df – DataFrame of standard network nodes

Returns: boolean

static network_connection_plot(G, disconnected_subgraph_nodes)

Plot a graph to check for network connection.

Parameters
  • G – OSMNX flavored networkX graph.

  • disconnected_subgraph_nodes – List of disconnected subgraphs described by the list of their member nodes (as described by their model_node_id).

returns: fig, ax : tuple

orig_dest_nodes_foreign_key(selection, node_foreign_key='')

Returns the foreign key id (whatever is used in the u and v variables in the links file) for the AB nodes as a tuple.

Parameters
  • selection – selection dictionary with A and B keys

  • node_foreign_key – variable name for whatever is used by the u and v variable

  • the links_df file. If nothing is specified (in) –

  • whatever (assume) –

  • is (default) –

Returns: tuple of (A_id, B_id)

Return type

tuple

static ox_graph(nodes_df, links_df)

create an osmnx-flavored network graph

osmnx doesn’t like values that are arrays, so remove the variables that have arrays. osmnx also requires that certain variables be filled in, so do that too.

Parameters
  • nodes_df – GeoDataFrame of nodes

  • link_df – GeoDataFrame of links

Returns: a networkx multidigraph

static read(link_file, node_file, shape_file, fast=False, recalculate_calculated_variables=False, recalculate_distance=False, parameters={})[source]

Reads in links and nodes network standard.

Parameters
  • link_file (str) – File path to link json.

  • node_file (str) – File path to node geojson.

  • shape_file (str) – File path to link true shape geojson

  • fast (bool) – boolean that will skip validation to speed up read time.

  • recalculate_calculated_variables (bool) – calculates fields from spatial joins, etc.

  • recalculate_distance (bool) – re-calculates distance.

  • parameters – dictionary of parameter settings (see Parameters class) or an instance of Parameters. If not specified, will use default parameters.

Returns

ModelRoadwayNetwork

static read_match_result(path)[source]

Reads the shst geojson match returns.

Returns shst dataframe.

Reading lots of same type of file and concatenating them into a single DataFrame.

Parameters

path (str) – File path to SHST match results.

Returns

geopandas geodataframe

Return type

geodataframe

##todo not sure why we need, but should be in utilities not this class

rename_variables_for_dbf(input_df, variable_crosswalk=None, output_variables=None, convert_geometry_to_xy=False)[source]

Rename attributes for DBF/SHP, make sure length within 10 chars.

Parameters
  • input_df (dataframe) – Network standard DataFrame.

  • variable_crosswalk (str) – File path to variable name crosswalk from network standard to DBF names.

  • output_variables (list) – List of strings for DBF variables.

  • convert_geometry_to_xy (bool) – True if converting node geometry to X/Y

Returns

dataframe

static roadway_net_to_gdf(roadway_net)

Turn the roadway network into a GeoDataFrame :param roadway_net: the roadway network to export

returns: shapes dataframe

Return type

GeoDataFrame

roadway_standard_to_met_council_network(output_epsg=None)[source]

Rename and format roadway attributes to be consistent with what metcouncil’s model is expecting.

Parameters

output_epsg (int) – epsg number of output network.

Returns

None

select_roadway_features(selection, search_mode='drive', force_search=False)

Selects roadway features that satisfy selection criteria

Example usage:
net.select_roadway_features(
selection = [ {

# a match condition for the from node using osm, # shared streets, or model node number ‘from’: {‘osm_model_link_id’: ‘1234’}, # a match for the to-node.. ‘to’: {‘shstid’: ‘4321’}, # a regex or match for facility condition # could be # of lanes, facility type, etc. ‘facility’: {‘name’:’Main St’}, }, … ])

Parameters

selection – dictionary with keys for: A - from node B - to node link - which includes at least a variable for name

Returns: a list of node foreign IDs on shortest path

Return type

GeoDataFrame

Parameters

selection_dictionary – Dictionary representation of selection of roadway features, containing a “link” key.

Returns: A boolean indicating if the selection dictionary contains

a required unique link id.

Return type

bool

selection_map(selected_link_idx, A=None, B=None, candidate_link_idx=[])

Shows which links are selected for roadway property change or parallel managed lanes category of roadway projects.

Parameters
  • selected_links_idx – list of selected link indices

  • candidate_links_idx – optional list of candidate link indices to also include in map

  • A – optional foreign key of starting node of a route selection

  • B – optional foreign key of ending node of a route selection

split_properties_by_time_period_and_category(properties_to_split=None)[source]

Splits properties by time period, assuming a variable structure of

Parameters

properties_to_split

dict dictionary of output variable prefix mapped to the source variable and what to stratify it by e.g. {

’trn_priority’ : {‘v’:’trn_priority’, ‘times_periods’:{“AM”: (“6:00”, “9:00”),”PM”: (“16:00”, “19:00”)}}, ‘ttime_assert’ : {‘v’:’ttime_assert’, ‘times_periods’:{“AM”: (“6:00”, “9:00”),”PM”: (“16:00”, “19:00”)}}, ‘lanes’ : {‘v’:’lanes’, ‘times_periods’:{“AM”: (“6:00”, “9:00”),”PM”: (“16:00”, “19:00”)}}, ‘ML_lanes’ : {‘v’:’ML_lanes’, ‘times_periods’:{“AM”: (“6:00”, “9:00”),”PM”: (“16:00”, “19:00”)}}, ‘price’ : {‘v’:’price’, ‘times_periods’:{“AM”: (“6:00”, “9:00”),”PM”: (“16:00”, “19:00”)}},’categories’: {“sov”: [“sov”, “default”],”hov2”: [“hov2”, “default”, “sov”]}}, ‘access’ : {‘v’:’access’, ‘times_periods’:{“AM”: (“6:00”, “9:00”),”PM”: (“16:00”, “19:00”)}},

}

Validate roadway network data link schema and output a boolean

static validate_node_schema(node_file, schema_location='roadway_network_node.json')

Validate roadway network data node schema and output a boolean

static validate_object_types(nodes, links, shapes)

Determines if the roadway network is being built with the right object types. Does not validate schemas.

Parameters
  • nodes – nodes geodataframe

  • links – link geodataframe

  • shapes – shape geodataframe

Returns: boolean

validate_properties(properties, ignore_existing=False, require_existing_for_change=False)

If there are change or existing commands, make sure that that property exists in the network.

Parameters
  • properties – properties dictionary to be evaluated

  • ignore_existing – If True, will only warn about properties that specify an “existing” value. If False, will fail.

  • require_existing_for_change – If True, will fail if there isn’t a specified value in theproject card for existing when a change is specified.

Returns: boolean value as to whether the properties dictonary is valid.

Return type

bool

validate_selection(selection)

Evaluate whetther the selection dictionary contains the minimum required values.

Parameters

selection – selection dictionary to be evaluated

Returns: boolean value as to whether the selection dictonary is valid.

Return type

Bool

static validate_shape_schema(shape_file, schema_location='roadway_network_shape.json')

Validate roadway network data shape schema and output a boolean

validate_uniqueness()

Confirms that the unique identifiers are met.

Return type

Bool

write(path='.', filename=None)

Writes a network in the roadway network standard

Parameters
  • path – the path were the output will be saved

  • filename – the name prefix of the roadway files that will be generated

Return type

None

write_roadway_as_fixedwidth(node_output_variables=None, link_output_variables=None, output_link_txt=None, output_node_txt=None, output_link_header_width_txt=None, output_node_header_width_txt=None, output_cube_network_script=None, drive_only=False)[source]

Writes out fixed width file.

This function does: 1. write out link and node fixed width data files for cube. 2. write out header and width correspondence. 3. write out cube network building script with header and width specification.

Parameters
  • node_output_variables (list) – list of node variable names.

  • link_output_variables (list) – list of link variable names.

  • output_link_txt (str) – File path to output link database.

  • output_node_txt (str) – File path to output node database.

  • output_link_header_width_txt (str) – File path to link column width records.

  • output_node_header_width_txt (str) – File path to node column width records.

  • output_cube_network_script (str) – File path to CUBE network building script.

  • drive_only (bool) – If True, only writes drive nodes and links

Returns

None

write_roadway_as_shp(node_output_variables=None, link_output_variables=None, data_to_csv=True, data_to_dbf=False, output_link_shp=None, output_node_shp=None, output_link_csv=None, output_node_csv=None)[source]

Write out dbf/shp for cube. Write out csv in addition to shp with full length variable names.

Parameters
  • node_output_variables (list) – List of strings for node output variables.

  • link_output_variables (list) – List of strings for link output variables.

  • data_to_csv (bool) – True if write network in csv format.

  • data_to_dbf (bool) – True if write network in dbf/shp format.

  • output_link_shp (str) – File path to output link dbf/shp.

  • output_node_shp (str) – File path to output node dbf/shp.

  • output_link_csv (str) – File path to output link csv.

  • output_node_csv (str) – File path to output node csv.

Returns

None

CALCULATED_VALUES = ['area_type', 'county', 'assign_group', 'centroidconnect']
CRS = 4326
KEEP_SAME_ATTRIBUTES_ML_AND_GP = ['distance', 'bike_access', 'drive_access', 'transit_access', 'walk_access', 'maxspeed', 'name', 'oneway', 'ref', 'roadway', 'length', 'segment_id']
MANAGED_LANES_NODE_ID_SCALAR = 500000
MANAGED_LANES_REQUIRED_ATTRIBUTES = ['A', 'B', 'model_link_id', 'locationReferences']
MANAGED_LANES_SCALAR = 500000
MAX_SEARCH_BREADTH = 10
MODES_TO_NETWORK_NODE_VARIABLES = {'bike': ['bike_node'], 'bus': ['bus_only', 'drive_node'], 'drive': ['drive_node'], 'rail': ['rail_only', 'drive_node'], 'transit': ['bus_only', 'rail_only', 'drive_node'], 'walk': ['walk_node']}
NODE_FOREIGN_KEY = 'model_node_id'
SEARCH_BREADTH = 5
SELECTION_REQUIRES = ['link']
SP_WEIGHT_FACTOR = 100
UNIQUE_NODE_IDENTIFIERS = ['model_node_id']
UNIQUE_NODE_KEY = 'model_node_id'
UNIQUE_SHAPE_KEY = 'shape_id'