Skip to content

build_future_hwys()

ccai-cmap edited this page Sep 25, 2025 · 32 revisions

build_future_hwys(subset = False, build_years = None) takes two arguments.

subset = False indicates that every project in the project table will be built, while build_years = None indicates that the years from input_years.csv will be built.

If subset = True, then subset_to_projects() will be called, and only the projects in the subset_hwy_projects.csv will be built.

If build_years = [list-of-years] is passed in, then the years in the list will be built, overriding the years from input_years.csv.

There are two parts to this method.

Part 1: Create combined gdb

create_combined_gdb() is called to store the built highway networks, as well project feature classes to easily verify that projects were applied correctly. At this point, the base links and nodes are copied over, and the feature class of all applied project coding is created, along with a feature class of project coding rows where multiple actions were applied to the same link, as those are particularly complicated.

What this actually looks like is that in the output folder, a gdb called MHN_all.gdb is created.

  • Inside, there is a feature dataset called hwylinks_all which will store all the built links. In that feature dataset there is a feature class of the base links.
  • Outside of that feature dataset, there is a feature class hwynode_all which contains the base nodes, a table coding_applied with all the applied project coding, and a table coding_multiple for the project coding rows where multiple actions were applied to the same link.

Part 2: Build future highway networks

This works as a for loop inside of a for loop. For example, let's say that the build years specified were 2020 and 2025. Then this can be visualized as:

--- 2015
|
|
--> 2020 
|   -> 2016 -> 2017 -> 2018 -> 2019 -> 2020
|
--> 2025 
    -> 2021 -> 2022 -> 2023 -> 2024 -> 2025

The outer for loop indicates what gdb is being worked on. MHN_2015.gdb gets copied to MHN_2020.gdb, and then MHN_2020.gdb gets copied to MHN_2025.gdb. Once the new geodatabase is created, the current geodatabase is set to that geodatabase.

The inner for loop pushes up the base year. Once MHN_2015.gdb gets copied to MHN_2020.gdb, the base year is still 2015, so the base year then gets pushed up to 2016, then 2017, up to 2020. The base year is pushed up by the method hwy_forward_one_year(). If you want to modify my code, it is EXTREMELY important to understand that method.

After the inner for loop completes, we are back in the outer for loop. The links of MHN_2020.gdb are now in their 2020 state, so we call copy_hwy_links() to copy the links over to MHN_all.gdb, and we add the path to MHN_2020.gdb to the list of built geodatabases. This also happens for 2025.

TODO: add the node (arterial, ramp, ghost) checks (in a new helper method).

Clone this wiki locally