Skip to content

Commit 94389b4

Browse files
authored
Merge pull request #119 from nmpeterson/master
Add IMAREA flag to nodes; prep for zones09-to-zones17 switch
2 parents a42ff55 + af7bc91 commit 94389b4

4 files changed

Lines changed: 50 additions & 97 deletions

File tree

MHN.py

Lines changed: 28 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'''
33
MHN.py
44
Author: npeterson
5-
Revised: 4/19/18
5+
Revised: 8/2/18
66
---------------------------------------------------------------------------
77
A class for importing into MHN processing scripts, containing frequently
88
used methods and variables.
@@ -27,6 +27,7 @@ class MasterHighwayNetwork(object):
2727
}
2828

2929
centroid_ranges = {
30+
## zones09
3031
'CBD': range( 1, 48), # NB. range(i,j) includes i & excludes j
3132
'Chicago': range( 1, 310),
3233
'Cook': range( 1, 855),
@@ -39,6 +40,24 @@ class MasterHighwayNetwork(object):
3940
'CMAP': range( 1, 1712),
4041
'MHN': range( 1, 1962),
4142
'POE': range(1945, 1962)
43+
44+
# ## zones17
45+
# 'CBD': range( 1, 48), # NB. range(i,j) includes i & excludes j
46+
# 'Chicago': range( 1, 718),
47+
# 'Cook': range( 1, 1733),
48+
# 'McHenry': range(2584, 2703),
49+
# 'Lake': range(2326, 2584),
50+
# 'Kane': range(2112, 2305),
51+
# 'DuPage': range(1733, 2112),
52+
# 'Will': range(2703, 2927),
53+
# 'Kendall': range(2305, 2326),
54+
# 'MHN': range( 1, 3650),
55+
# 'POE': range(3633, 3650),
56+
# 'CMAP': {
57+
# '7_Counties': range( 1, 2927),
58+
# 'Grundy_Part': range(2949, 2950),
59+
# 'DeKalb_Part': range(2977, 2978)
60+
# }
4261
}
4362

4463
min_node_id = 5001 # 1-5000 reserved for zone centroids/POEs
@@ -96,68 +115,6 @@ class MasterHighwayNetwork(object):
96115
'4': ('1', '5') # Off-peak periods
97116
}
98117

99-
mcps = {
100-
'100001': "Elgin O'Hare Expressway Improvements (including Western O'Hare Bypass)",
101-
'100002': "I-190 Access Improvements",
102-
'100003': "I-90 Add/Managed Lanes",
103-
'100004': "Central Lake County Corridor (IL 53 North and IL 120)",
104-
'100005': "I-290 Multimodal Corridor",
105-
'100006': "I-55 Managed Lanes",
106-
'100007': "I-94 Add Lanes North",
107-
'100008': "I-80 Add Lanes (US 30 to US 45)",
108-
'100009': "I-294/I-57 Interchange",
109-
'100010': "I-88 Add Lanes",
110-
'100011': "Illiana Expressway",
111-
'100012': "Circle Interchange Reconstruction",
112-
'101001': "I-80 Add/Managed Lanes",
113-
'101002': "I-57 Add Lanes",
114-
'101003': "I-55 Add Lanes and Reconstruction",
115-
'101004': "IL 394",
116-
'101005': "Prairie Parkway",
117-
'101006': "McHenry-Lake Corridor",
118-
'101007': "Elgin O'Hare Expressway West Extension",
119-
'101008': "Elgin O'Hare Expressway Far West Extension",
120-
'101009': "I-80 to I-55 Connector",
121-
'101010': "I-80 Managed Lanes",
122-
'101011': "I-294 Central Tristate Mobility Improvements",
123-
'200001': "CTA South Red Line Extension",
124-
'200002': "Metra UP North Improvements",
125-
'200003': "Metra UP Northwest Improvements and Extension",
126-
'200004': "Metra Rock Island Improvements",
127-
'200005': "West Loop Transportation Center (Phase 1)",
128-
'200006': "Metra SouthWest Service Improvements",
129-
'200007': "CTA North Red and Purple Line Improvements",
130-
'200008': "Metra UP West Improvements",
131-
'200009': "West Loop Transportation Center (Phase 2)",
132-
'201001': "Metra SouthEast Service Corridor",
133-
'201002': "Mid-City Transitway",
134-
'201003': "CTA Orange Line Extension",
135-
'201004': "CTA Yellow Line Enhancements and Extension",
136-
'201005': "Metra Rock Island Extension",
137-
'201006': "Metra Heritage Corridor Improvements",
138-
'201007': "Metra SouthWest Service Extension and Full Service",
139-
'201008': "Express Airport Train Service",
140-
'201009': "Metra Milwaukee District North Extension",
141-
'201010': "South Lakefront Corridor",
142-
'201011': "CTA Brown Line Extension",
143-
'201012': "O'Hare to Schaumburg Transit Service",
144-
'201013': "Metra North Central Service Improvements",
145-
'201014': "Metra Electric District Extension",
146-
'201015': "Metra Milwaukee District West Extension",
147-
'201016': "Metra Milwaukee District West Improvements",
148-
'201017': "Metra Milwaukee District North Improvement",
149-
'201018': "Inner Circumferential Rail Service",
150-
'201019': "DuPage 'J' Line",
151-
'201020': "Central Area Transitway",
152-
'201021': "CTA Blue Line West Extension",
153-
'201022': "CTA Circle Line (Phase III, north)",
154-
'201023': "Metra BNSF Extension",
155-
'201024': "CTA Circle Line (Phase II, south)",
156-
'201025': "Metra STAR Line Corridor",
157-
'201026': "Metra BNSF Improvements",
158-
'201027': "Metra Electric District Improvements",
159-
}
160-
161118
rsps = {
162119
3: "McHenry-Lake Corridor",
163120
6: "IL-31 Front St",
@@ -323,6 +280,14 @@ def __init__(self, mhn_gdb_path, zone_gdb_path=None):
323280
self.subzone_attr = 'Subzone09'
324281
self.capzone = os.path.join(self.zone_gdb, 'zonesys09', 'capzones09')
325282
self.capzone_attr = 'CapacityZone09'
283+
# self.zone = os.path.join(self.zone_gdb, 'zonesys17', 'zones17')
284+
# self.zone_attr = 'Zone17'
285+
# self.subzone = os.path.join(self.zone_gdb, 'zonesys17', 'subzones17')
286+
# self.subzone_attr = 'Subzone17'
287+
# self.capzone = os.path.join(self.zone_gdb, 'zonesys17', 'capzones17')
288+
# self.capzone_attr = 'CapacityZone17'
289+
self.imarea = os.path.join(self.zone_gdb, 'imarea18')
290+
self.imarea_attr = 'IMArea'
326291

327292
# Misc.
328293
self.mhn2iris_name = 'mhn2iris'

generate_highway_files.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'''
33
generate_highway_files.py
44
Author: npeterson
5-
Revised: 5/11/17
5+
Revised: 8/3/18
66
---------------------------------------------------------------------------
77
This program creates the Emme highway batchin files needed to model a
88
scenario network. The scenario, output path and CT-RAMP flag are passed to
@@ -194,7 +194,7 @@ def generate_node_zones_csv(out_csv):
194194
hwy_anodes = [abb.split('-')[0] for abb in hwy_abb_2]
195195
hwy_bnodes = [abb.split('-')[1] for abb in hwy_abb_2]
196196
hwy_nodes_list = list(set(hwy_anodes).union(set(hwy_bnodes)))
197-
hwy_nodes_attr = ['NODE', 'POINT_X', 'POINT_Y', MHN.zone_attr, MHN.capzone_attr]
197+
hwy_nodes_attr = ['NODE', 'POINT_X', 'POINT_Y', MHN.zone_attr, MHN.capzone_attr, MHN.imarea_attr]
198198
hwy_nodes_query = '"NODE" IN ({0})'.format(','.join(hwy_nodes_list))
199199
hwy_nodes_view = MHN.make_skinny_table_view(MHN.node, 'hwy_nodes_view', hwy_nodes_attr, hwy_nodes_query)
200200
MHN.write_attribute_csv(hwy_nodes_view, hwy_nodes_csv, hwy_nodes_attr)
@@ -230,27 +230,6 @@ def generate_node_zones_csv(out_csv):
230230
lanemiles = float(attr[3]) * int(attr[6])
231231
mainline_lanemiles[ab] = lanemiles
232232

233-
# Create mcp_stats.txt.
234-
scen_mcp_tipids = {}
235-
scen_mcp_query = ''' "COMPLETION_YEAR" <= {0} AND "MCP_ID" IS NOT NULL '''.format(scen_year)
236-
with arcpy.da.SearchCursor(MHN.hwyproj, ['MCP_ID', hwyproj_id_field], scen_mcp_query) as c:
237-
for mcp_id, tipid in c:
238-
if mcp_id not in scen_mcp_tipids:
239-
scen_mcp_tipids[mcp_id] = set([tipid])
240-
else:
241-
scen_mcp_tipids[mcp_id].add(tipid)
242-
243-
mcp_stats = os.path.join(scen_path, 'mcp_stats.csv')
244-
with open(mcp_stats, 'w') as w:
245-
w.write('MCP_ID,MCP_NAME,MAINLINE_LANEMILES\n')
246-
for mcp_id in sorted(scen_mcp_tipids.keys()):
247-
mcp_query = ''' "{0}" IN ('{1}') '''.format(hwyproj_id_field, "','".join(scen_mcp_tipids[mcp_id]))
248-
mcp_ab = set((r[0].rsplit('-', 1)[0] for r in arcpy.da.SearchCursor(MHN.route_systems[MHN.hwyproj][0], ['ABB'], mcp_query)))
249-
mcp_lanemiles = sum((mainline_lanemiles[ab] for ab in mcp_ab if ab in mainline_lanemiles))
250-
w.write('{0},{1},{2}\n'.format(mcp_id, MHN.mcps[mcp_id], mcp_lanemiles))
251-
252-
arcpy.AddMessage('-- Scenario {0} mcp_stats.csv generated successfully.'.format(scen))
253-
254233
# Create rsp_stats.txt.
255234
scen_rsp_tipids = {}
256235
scen_rsp_query = ''' "COMPLETION_YEAR" <= {0} AND "RSP_ID" IS NOT NULL '''.format(scen_year)

generate_highway_files_2.sas

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
generate_highway_files_2.sas
33
Authors: cheither, npeterson, nferguson & tschmidt
4-
Revised: 5/4/17
4+
Revised: 8/3/18
55
---------------------------------------------------------------------------
66
Program uses base conditions and project data from the MHN to build Emme
77
scenario highway networks. Emme batchin files are the output of this
@@ -405,7 +405,8 @@ data coord; infile in4 dlm=',' dsd firstobs=2;
405405
x
406406
y
407407
zone
408-
areatype;
408+
areatype
409+
imarea;
409410

410411
** Zone09 area definitions **;
411412
if 1 <= zone <= 854 then area = '01. Cook Co.';
@@ -562,11 +563,12 @@ data coord; infile in4 dlm=',' dsd firstobs=2;
562563
** WRITE OUT NODE ATTRIBUTE FILE FOR EMME **;
563564
data out4; set anodes;
564565
file out5;
565-
if _n_= 1 then put 'c i-node,@zone,@atype';
566+
if _n_= 1 then put 'c i-node,@zone,@atype,@imarea';
566567
put
567568
@1 node 6. +1
568569
zone +1
569-
areatype;
570+
areatype +1
571+
imarea;
570572

571573
%mend output;
572574

incorporate_edits.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'''
33
incorporate_edits.py
44
Author: npeterson
5-
Revised: 5/4/17
5+
Revised: 8/2/18
66
---------------------------------------------------------------------------
77
This script should be run after any geometric edits have been made to the
88
Master Highway Network. It will:
@@ -329,18 +329,25 @@
329329
# -----------------------------------------------------------------------------
330330
# Update node/arc attributes.
331331
# -----------------------------------------------------------------------------
332-
# Calculate node ZONE and AREATYPE using Identity tool.
332+
# Calculate node SUBZONE, ZONE and CAPACITY ZONE using Identity tool
333333
new_nodes_CZ = os.path.join(MHN.mem, 'new_nodes_CZ')
334334
subzone_lyr = MHN.make_skinny_feature_layer(MHN.subzone, 'subzone_lyr', [MHN.zone_attr, MHN.subzone_attr, MHN.capzone_attr])
335335
arcpy.Identity_analysis(new_nodes, subzone_lyr, new_nodes_CZ, 'NO_FID')
336336

337-
arcpy.DeleteIdentical_management(new_nodes_CZ, ['Shape', 'NODE']) # Delete (arbitrarily) duplicates created from nodes lying exactly on border of 2+ zones/capzones
338-
with arcpy.da.UpdateCursor(new_nodes_CZ, ['NODE', MHN.zone_attr, MHN.subzone_attr, MHN.capzone_attr]) as zoned_nodes_cursor:
337+
# Calculate node IM AREA using Identity tool
338+
new_nodes_CZI = os.path.join(MHN.mem, 'new_nodes_CZI')
339+
imarea_lyr = MHN.make_skinny_feature_layer(MHN.imarea, 'imarea_lyr', [MHN.imarea_attr])
340+
arcpy.Identity_analysis(new_nodes_CZ, imarea_lyr, new_nodes_CZI, 'NO_FID')
341+
342+
# Delete (arbitrarily) duplicates created from nodes lying exactly on border of 2+ subzone/zone/capzone/imarea polys
343+
arcpy.DeleteIdentical_management(new_nodes_CZI, ['Shape', 'NODE'])
344+
with arcpy.da.UpdateCursor(new_nodes_CZI, ['NODE', MHN.zone_attr, MHN.subzone_attr, MHN.capzone_attr, MHN.imarea_attr]) as zoned_nodes_cursor:
339345
for zoned_node in zoned_nodes_cursor:
340346
node = zoned_node[0]
341347
zone = zoned_node[1]
342348
subzone = zoned_node[2]
343349
capzone = zoned_node[3]
350+
imarea = zoned_node[4]
344351
if MHN.min_poe <= node <= MHN.max_poe and zone > 0:
345352
MHN.die('POE {0} is in zone {1}! Please move it outside of the modeling area.'.format(str(node), str(zone)))
346353
raise arcpy.ExecuteError
@@ -358,7 +365,7 @@
358365
arcpy.AddWarning('-- WARNING: Zone ' + str(node) + ' centroid is in zone ' + str(zone) + '! Please verify that this is intentional.')
359366
else:
360367
pass
361-
arcpy.AddMessage('-- Node {0}, {1} & {2} fields recalculated'.format(MHN.zone_attr, MHN.subzone_attr, MHN.capzone_attr))
368+
arcpy.AddMessage('-- Node {}, {}, {} & {} fields recalculated'.format(MHN.zone_attr, MHN.subzone_attr, MHN.capzone_attr, MHN.imarea_attr))
362369

363370
# Calculate arc ANODE and BNODE values.
364371
anodes_id = os.path.join(MHN.mem, 'anodes_id')
@@ -700,8 +707,8 @@ def update_route_system(header, itin, vertices_comprising, split_dict_ABB, new_A
700707
# Replace old nodes.
701708
arcpy.AddMessage('-- {0}...'.format(MHN.node))
702709
arcpy.TruncateTable_management(MHN.node)
703-
arcpy.Append_management(new_nodes_CZ, MHN.node, 'TEST')
704-
arcpy.Delete_management(new_nodes_CZ)
710+
arcpy.Append_management(new_nodes_CZI, MHN.node, 'TEST')
711+
arcpy.Delete_management(new_nodes_CZI)
705712

706713
# Replace route system tables and line FCs.
707714
for updated_route_system in updated_route_systems_list:

0 commit comments

Comments
 (0)