-
Notifications
You must be signed in to change notification settings - Fork 0
HN Module
The HN module refers to modules/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.
15 attributes are defined. There are 8 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_travelfolder. -
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_travelfolder. (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). - 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 6 main methods (which are used in other scripts) and 8 helper methods (which are called by the main methods).
- create_base_hwy(): 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_hwyproj_coding(): imports new highway projects from a spreadsheet.
- check_hwyproj_coding_table(): checks the validity of the highway project coding table. (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.

The diagram above describes the order which the methods should be called if you are building your own script. Order is important, as the HN object changes as the methods are called. For example, to get to 4 (checking the highway project table), you can either do 1-2-4 or 1-2-3-4. If you're starting anywhere besides create_base_hwy(), be careful to ensure that the HN attributes are set correctly beforehand.
- 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).
- get_field_domain_dict(): returns a dictionary like field: domain for all fields in a feature class.
- get_domain_dicts(): returns two dictionaries: one dictionary for the coded value domains, and another dictionary for the range domains, of a geodatabase.
- 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.
- add_rcs: adds relationship classes back into the current geodatabase.