Skip to content

HN Module

ccai-cmap edited this page Jul 27, 2025 · 97 revisions

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.

Attributes

15 attributes are defined. There are 8 final attributes which do not change, and 7 which get updated by the methods.

Final Attributes

  1. in_folder: the absolute path to the mfhrn_programs/input folder.
  2. mhn_in_folder: the absolute path to the mfhrn_programs/input/1_MHN folder.
  3. in_gdb: the absolute path to mfhrn_programs/input/1_MHN/MHN.gdb.
  4. mhn_out_folder: the absolute path to the mfhrn_programs/output/1_MHN folder. (The actual folder does not necessarily exist yet. This is just the path.)
  5. years_list: a list of the years that were passed into years.csv (located in the input folder).
  6. hwy_files: a list of names of the files in the MHN gdb which have to do solely with the highway network.
  7. bus_files: a list of names of the files in the MHN gdb which have to do with the bus network.
  8. rel_classes: a list of the names of the relationship classes in the MHN gdb.

Non-Final Attributes

  1. current_gdb: this describes the absolute path to the gdb which is currently being worked with.
  2. 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).
  3. hwylink_df: a pandas dataframe representation of the hwynet/hwynet_arc feature class in the current gdb, with geometry dropped.
  4. hwynode_df: a pandas dataframe representation of the hwynet/hwynet_node feature class in the current gdb, with geometry dropped.
  5. hwyproj_df: a pandas dataframe represention of the hwyproj_coding table in the current gdb.
  6. hwyproj_years_df: a pandas dataframe representation of the hwynet/hwyproj feature class in the current gdb, with only the TIPID + COMPLETION_YEAR fields.
  7. built_gdbs: a list of the built gdbs in the output folder.

Methods

These are the building blocks for the rest of the scripts. There are 7 main methods (which are used in other scripts) and 7 helper methods (which are called by the main methods).

Main Methods

  1. generate_base_year(): makes a copy of the GDB in the output directory with the relationships removed.
  2. import_hwy_projects(): imports new highway projects from a spreadsheet.
  3. check_hwy_fcs(): checks the validity of the base feature classes.
  4. check_hwy_project_table(): checks the validity of the base highway project coding. (translates coding_overlap.sas and import_highway_projects_2.sas)
  5. 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)
  6. 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.
  7. generate_hwy_files(): generates the highway files for the EMME model. (translates the second half of generate_highway_files_2.sas)

Helper Methods

  1. get_hwy_dfs(): reads hwylink_df, hwynode_df, hwyproj_df, and hwyproj_years_df from the data in current_gdb.
  2. del_rcs(): deletes the relationship classes specified by rel_classes out of current_gdb.
  3. copy_gdb_safe(): copies a gdb in a safe way (because arcpy's Copy frequently crashes on me, T_T).
  4. subset_to_projects(): sets the "USE" field of projects outside the chosen subset (like RSP) to 0, so that they won't be applied.
  5. 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.
  6. copy_hwy_links(): copies the current highway links into the combined gdb.
  7. hwy_forward_one_year(): moves the highway base year up one year.

Clone this wiki locally