Skip to content

Commit

Permalink
Highway Network Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jawadmhoque committed Feb 21, 2024
1 parent 6ee4a38 commit 186de4f
Show file tree
Hide file tree
Showing 4 changed files with 19,045 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lasso/mtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def calculate_facility_type(
join_gdf["oneWay"].fillna("", inplace = True)
join_gdf["oneWay"] = join_gdf["oneWay"].apply(lambda x: "NA" if x in [None, np.nan, float('nan')] else x)
join_gdf["oneWay"] = join_gdf["oneWay"].apply(lambda x: str(x) if type(x) == bool else x)
join_gdf["oneWay"] = join_gdf["oneWay"].apply(lambda x: str(x) if type(x) == int else x)
join_gdf["oneWay"] = join_gdf["oneWay"].apply(lambda x: x if type(x) == str else ','.join(map(str, x)))
join_gdf["oneWay_binary"] = join_gdf["oneWay"].apply(lambda x: 0 if "False" in x else 1)

Expand Down Expand Up @@ -1710,7 +1711,7 @@ def roadway_standard_to_mtc_network(
roadway_network.links_df["assignable"]
)

roadway_network = calculate_cntype(roadway_network, parameters)
roadway_network = calculate_cntype(roadway_network, parameters, overwrite=True)
roadway_network = calculate_transit(roadway_network, parameters)
roadway_network = calculate_useclass(roadway_network, parameters)
roadway_network = calculate_facility_type(roadway_network, parameters, update_network_variable = True)
Expand Down
20 changes: 13 additions & 7 deletions lasso/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ def __init__(self, **kwargs):
#MTC
'name',
"distance",
#"roadway",
"roadway",
#"name",
#MC
#"shape_id",
Expand Down Expand Up @@ -770,6 +770,7 @@ def __init__(self, **kwargs):
"managed",
"bus_only",
"rail_only",
"pnr",
#MTC
"assignable",
"cntype",
Expand All @@ -796,6 +797,8 @@ def __init__(self, **kwargs):
#bi-county
"nmt2010",
"nmt2020",
"BRT",
"has_transit"
]

self.output_link_shp = os.path.join(self.scratch_location, "links.shp")
Expand All @@ -821,7 +824,7 @@ def __init__(self, **kwargs):

self.fare_matrix_output_variables = ["faresystem", "origin_farezone", "destination_farezone", "price"]

self.zones = 4756
self.zones = 6593
"""
Create all the possible headway variable combinations based on the cube time periods setting
"""
Expand Down Expand Up @@ -907,6 +910,8 @@ def __init__(self, **kwargs):
#bi-county
"nmt2010",
"nmt2020",
"BRT",
"has_transit"
]

self.float_col = [
Expand All @@ -922,6 +927,7 @@ def __init__(self, **kwargs):
self.string_col = [
"osm_node_id",
"name",
"pnr",
"roadway",
"shstGeometryId",
"access_AM",
Expand All @@ -938,10 +944,10 @@ def __init__(self, **kwargs):

self.drive_buffer = 6

self.network_build_crs = CRS("EPSG:2875")
self.project_card_crs = CRS("EPSG:4326")
self.transformer = pyproj.Transformer.from_crs(
self.network_build_crs, self.project_card_crs, always_xy=True
)
#self.network_build_crs = CRS("EPSG:2875")
#self.project_card_crs = CRS("EPSG:4326")
#self.transformer = pyproj.Transformer.from_crs(
# self.network_build_crs, self.project_card_crs, always_xy=True
#)

self.__dict__.update(kwargs)
3 changes: 3 additions & 0 deletions lasso/roadway.py
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,9 @@ def dataframe_to_fixed_width(df):
dict: dictionary with columns names as keys, column width as values.
"""
WranglerLogger.info("Starting fixed width conversion")
if 'name' in df.columns:
df['name']=df['name'].apply(lambda x: x.strip().split(',')[0].replace("[",'').replace("'nan'","").replace("nan","").replace("'",""))


# get the max length for each variable column
max_width_dict = dict(
Expand Down
Loading

0 comments on commit 186de4f

Please sign in to comment.