-
Notifications
You must be signed in to change notification settings - Fork 0
HN Module
The HN module refers to a_HN.py. This file contains the HighwayNetwork class, which describes the attributes and methods for a HighwayNetwork object. It is meant to work ONLY with highway data. It does not contain functionality for working with bus data.
16 attributes are defined. There are 9 final attributes which do not change, and 7 which get updated by the methods.
-
in_folder: the absolute path to the
mfhrn_programs/inputfolder. -
mhn_in_folder: the absolute path to the
mfhrn_programs/input/1_MHNfolder. -
mhn_in_gdb: the absolute path to
mfhrn_programs/input/1_MHN/MHN.gdb. -
mhn_out_folder: the absolute path to the
mfhrn_programs/output/1_MHNfolder. (The actual folder does not necessarily exist yet. This is just the path.) -
years_list: a list of the years that were passed into
input_years.csv(located in the input folder). -
years_dict: a dictionary of the years that were passed into
input_years.csvand their corresponding scenarios. - hwy_files: a list of names of the files in the MHN gdb which have to do solely with the highway network.
- bus_files: a list of names of the files in the MHN gdb which have to do with the bus network.
- rel_classes: a list of the names of the relationship classes in the MHN gdb.
- current_gdb: this describes the absolute path to the gdb which is currently being worked with.
- base_year: starts off as the actual base year of the MHN, and changes as updates are applied. (For example, it starts off at 2015, and after a year of changes have been applied, it changes to 2016).
- hwylink_df: a pandas dataframe representation of the hwynet/hwynet_arc feature class in the current gdb, with geometry dropped.
- hwynode_df: a pandas dataframe representation of the hwynet/hwynet_node feature class in the current gdb, with geometry dropped.
- hwyproj_df: a pandas dataframe represention of the hwyproj_coding table in the current gdb.
- hwyproj_years_df: a pandas dataframe representation of the hwynet/hwyproj feature class in the current gdb, with only the TIPID + COMPLETION_YEAR fields.
- built_gdbs: a list of the built gdbs in the output folder.
These are the building blocks for the rest of the scripts. There are 7 main methods (which are used in other scripts) and 8 helper methods (which are called by the main methods).
- generate_base_year(): makes a copy of the GDB in the output directory with the relationships removed.
- check_hwy_fcs(): checks the validity of the base feature classes.
- import_hwy_project_coding(): imports new highway projects from a spreadsheet.
- check_hwy_project_table(): checks the validity of the base highway project coding. (translates coding_overlap.sas and import_highway_projects_2.sas)
- build_future_hwys(): builds the network for the years specified in the years csv. (translates process_highway_coding.sas and the first half of generate_highway_files_2.sas)
- finalize_hwy_data(): drops rows marked for deletion, removes added fields and comments, and ensures that all of the hwy_files agree with each other.
- generate_hwy_files(): generates the highway files for the EMME model. (translates the second half of generate_highway_files_2.sas)

The diagram above describes the order which the methods should be called if you are building your own script. Order is important: you MUST start at 1 (generating the base year) no matter what. Even if you already have the output folder created, the HN object will not have the correct attributes if you don't start there.
For example, to get to 4 (checking the highway project table), you can either do 1-2-4 or 1-2-3-4. As long as your script takes a valid path, it works.
- get_hwy_fields: returns (1) a list of the link fields, (2) a dictionary of the link fields, (3) a list of the project coding fields, and (4) a dictionary of the project coding fields.
- get_hwy_dfs(): reads hwylink_df, hwynode_df, hwyproj_df, and hwyproj_years_df from the data in current_gdb.
- del_rcs(): deletes the relationship classes specified by rel_classes out of current_gdb.
- copy_gdb_safe(): copies a gdb in a safe way (because arcpy's Copy occasionally crashes on me, T_T).
- subset_to_projects(): sets the "USE" field of projects outside the chosen subset (like RSP) to 0, so that they won't be applied.
- copy_hwy_links(): copies the current highway links into the combined gdb.
- create_combined_gdb(): creates a gdb to store all the built highway networks, as well as project feature classes to easily verify how projects were applied.
- hwy_forward_one_year(): moves the highway base year up one year.