"PARKRES1",
        "PARKRES2",
        "SIGIC",
        "CLTL",
        "RRGRADECROSS",
        "TOLLDOLLARS",
        "MODES",
        "CHIBLVD",
        "TRUCKRES",
        "VCLEARANCE",
        "MILES",
    ]
    hwy_network_query = """ "BASELINK" = '1' OR "ABB" IN ('{0}') """.format(
        "','".join((abb for abb in hwy_abb if abb[-1] != "1"))
    )
    hwy_network_lyr = MHN.make_skinny_feature_layer(MHN.arc, "hwy_network_lyr", hwy_network_attr, hwy_network_query)
    MHN.write_attribute_csv(hwy_network_lyr, hwy_network_csv, hwy_network_attr)
    hwy_abb_2 = [r[0] for r in arcpy.da.SearchCursor(hwy_network_lyr, ["ABB"])]

    hwy_anodes = [abb.split("-")[0] for abb in hwy_abb_2]
    hwy_bnodes = [abb.split("-")[1] for abb in hwy_abb_2]
    hwy_nodes_list = list(set(hwy_anodes).union(set(hwy_bnodes)))
    hwy_nodes_attr = ["NODE", "POINT_X", "POINT_Y", "Zone09", "CapacityZone09"]
    hwy_nodes_query = '"NODE" IN ({0})'.format(",".join(hwy_nodes_list))
    hwy_nodes_view = MHN.make_skinny_table_view(MHN.node, "hwy_nodes_view", hwy_nodes_attr, hwy_nodes_query)
    MHN.write_attribute_csv(hwy_nodes_view, hwy_nodes_csv, hwy_nodes_attr)
    arcpy.Delete_management(hwy_nodes_view)

    # Process attribute tables with generate_highway_files_2.sas.
    sas2_sas = os.path.join(MHN.prog_dir, "{0}.sas".format(sas2_name))
    sas2_args = [hwy_path, scen, str(MHN.max_poe), str(MHN.base_year)]
transact_attr = [hwyproj_id_field,'ACTION_CODE','NEW_DIRECTIONS','NEW_TYPE1','NEW_TYPE2','NEW_AMPM1','NEW_AMPM2','NEW_POSTEDSPEED1',
                 'NEW_POSTEDSPEED2','NEW_THRULANES1','NEW_THRULANES2','NEW_THRULANEWIDTH1','NEW_THRULANEWIDTH2','ADD_PARKLANES1',
                 'ADD_PARKLANES2','ADD_SIGIC','ADD_CLTL','ADD_RRGRADECROSS','NEW_TOLLDOLLARS','NEW_MODES','TOD','ABB','REP_ANODE','REP_BNODE']
transact_query = '"{0}" IN (\'{1}\')'.format(hwyproj_id_field, "','".join((hwyproj_id for hwyproj_id in hwy_projects)))
transact_view = MHN.make_skinny_table_view(MHN.route_systems[MHN.hwyproj][0], 'transact_view', transact_attr, transact_query)
MHN.write_attribute_csv(transact_view, transact_csv, transact_attr)
hwy_abb = MHN.make_attribute_dict(transact_view, 'ABB', attr_list=[])
arcpy.Delete_management(transact_view)

# Export arc & node attributes of all baselinks and skeletons used in
# projects completed by scenario year.
network_attr = ['ANODE','BNODE','ABB','DIRECTIONS','TYPE1','TYPE2','AMPM1','AMPM2','POSTEDSPEED1','POSTEDSPEED2',
                'THRULANES1','THRULANES2','THRULANEWIDTH1','THRULANEWIDTH2','PARKLANES1','PARKLANES2','BASELINK',
                'SIGIC','CLTL','RRGRADECROSS','TOLLDOLLARS','MODES','MILES']
network_query = '"BASELINK" = \'1\' OR "ABB" IN (\'{0}\')'.format("','".join((abb for abb in hwy_abb if abb[-1] != '1')))
network_lyr = MHN.make_skinny_feature_layer(MHN.arc, 'network_lyr', network_attr, network_query)
MHN.write_attribute_csv(network_lyr, network_csv, network_attr)

# Process attribute tables with export_future_network_2.sas.
sas1_sas = os.path.join(MHN.util_dir, '{0}.sas'.format(sas1_name))
sas1_args = [network_csv, transact_csv, year_csv, update_link_csv, flag_node_csv, build_year, MHN.max_poe, MHN.base_year]
MHN.submit_sas(sas1_sas, sas1_log, sas1_lst, sas1_args)
if not os.path.exists(sas1_log):
    MHN.die('{0} did not run!'.format(sas1_sas))
else:
    os.remove(sas1_log)
    MHN.delete_if_exists(sas1_lst)
    os.remove(year_csv)
    os.remove(transact_csv)
    os.remove(network_csv)
Exemplo n.º 3
0
MHN.delete_if_exists(oneline_itin_txt)
MHN.delete_if_exists(feed_groups_txt)
MHN.delete_if_exists(missing_links_csv)
MHN.delete_if_exists(link_dict_txt)
MHN.delete_if_exists(short_path_txt)
MHN.delete_if_exists(path_errors_txt)


# -----------------------------------------------------------------------------
#  Create features/layers that will be same for all scenarios & TODs.
# -----------------------------------------------------------------------------
arc_miles_view = 'arc_miles_view'
MHN.make_skinny_table_view(MHN.arc, arc_miles_view, ['ABB', 'MILES'])

node_oid_field = MHN.determine_OID_fieldname(MHN.node)
centroid_lyr = MHN.make_skinny_feature_layer(MHN.node, 'centroid_lyr', [node_oid_field, 'NODE'], '"NODE" <= {0}'.format(max(MHN.centroid_ranges['MHN'])))
centroid_fc = os.path.join(MHN.mem, 'centroid_fc')
arcpy.CopyFeatures_management(centroid_lyr, centroid_fc)

zone_lyr = MHN.make_skinny_feature_layer(MHN.zone, 'zone_lyr', [MHN.zone_attr])


# -----------------------------------------------------------------------------
#  Identify representative runs from GTFS bus itineraries.
# -----------------------------------------------------------------------------
rep_runs_dict = {}
bus_fc_dict = {MHN.bus_base: 'base',
               MHN.bus_current: 'current'}

# Remove base or current from bus_fc_dict, if not used for specified scenarios.
if not any(MHN.scenario_years[scen] < MHN.bus_years['current'] for scen in scen_list):
Exemplo n.º 4
0
    hwy_abb = [r[0] for r in arcpy.da.SearchCursor(hwy_transact_view, ['ABB'])]
    arcpy.Delete_management(hwy_transact_view)

    # Export arc & node attributes of all baselinks and skeletons used in
    # projects completed by scenario year.
    hwy_network_attr = [
        'ANODE', 'BNODE', 'ABB', 'DIRECTIONS', 'TYPE1', 'TYPE2', 'AMPM1',
        'AMPM2', 'POSTEDSPEED1', 'POSTEDSPEED2', 'THRULANES1', 'THRULANES2',
        'THRULANEWIDTH1', 'THRULANEWIDTH2', 'PARKLANES1', 'PARKLANES2',
        'PARKRES1', 'PARKRES2', 'SIGIC', 'CLTL', 'RRGRADECROSS', 'TOLLDOLLARS',
        'MODES', 'CHIBLVD', 'TRUCKRES', 'VCLEARANCE', 'MILES'
    ]
    hwy_network_query = ''' "BASELINK" = '1' OR "ABB" IN ('{0}') '''.format(
        "','".join((abb for abb in hwy_abb if abb[-1] != '1')))
    hwy_network_lyr = MHN.make_skinny_feature_layer(MHN.arc, 'hwy_network_lyr',
                                                    hwy_network_attr,
                                                    hwy_network_query)
    MHN.write_attribute_csv(hwy_network_lyr, hwy_network_csv, hwy_network_attr)
    hwy_abb_2 = [r[0] for r in arcpy.da.SearchCursor(hwy_network_lyr, ['ABB'])]

    hwy_anodes = [abb.split('-')[0] for abb in hwy_abb_2]
    hwy_bnodes = [abb.split('-')[1] for abb in hwy_abb_2]
    hwy_nodes_list = list(set(hwy_anodes).union(set(hwy_bnodes)))
    hwy_nodes_attr = [
        'NODE', 'POINT_X', 'POINT_Y', MHN.zone_attr, MHN.capzone_attr
    ]
    hwy_nodes_query = '"NODE" IN ({0})'.format(','.join(hwy_nodes_list))
    hwy_nodes_view = MHN.make_skinny_table_view(MHN.node, 'hwy_nodes_view',
                                                hwy_nodes_attr,
                                                hwy_nodes_query)
    MHN.write_attribute_csv(hwy_nodes_view, hwy_nodes_csv, hwy_nodes_attr)
Exemplo n.º 5
0
    MHN.die(
        '''The following nodes are referenced in {0}, but no longer exist '''
        '''in the network or are zone centroids: {1}. Please update the '''
        '''table to reference only existing, non-centroid nodes.'''
        ''.format(MHN.pnr, bad_pnr_node_str)
    )
else:
    arcpy.AddMessage('-- Park-n-Ride NODE values verified')


# -----------------------------------------------------------------------------
#  Update node/arc attributes.
# -----------------------------------------------------------------------------
# Calculate node ZONE and AREATYPE using Identity tool.
new_nodes_CZ = os.path.join(MHN.mem, 'new_nodes_CZ')
subzone_lyr = MHN.make_skinny_feature_layer(MHN.subzone, 'subzone_lyr', [MHN.zone_attr, MHN.subzone_attr, MHN.capzone_attr])
arcpy.Identity_analysis(new_nodes, subzone_lyr, new_nodes_CZ, 'NO_FID')

arcpy.DeleteIdentical_management(new_nodes_CZ, ['Shape', 'NODE'])  # Delete (arbitrarily) duplicates created from nodes lying exactly on border of 2+ zones/capzones
with arcpy.da.UpdateCursor(new_nodes_CZ, ['NODE', MHN.zone_attr, MHN.subzone_attr, MHN.capzone_attr]) as zoned_nodes_cursor:
    for zoned_node in zoned_nodes_cursor:
        node = zoned_node[0]
        zone = zoned_node[1]
        subzone = zoned_node[2]
        capzone = zoned_node[3]
        if MHN.min_poe <= node <= MHN.max_poe and zone > 0:
            MHN.die('POE {0} is in zone {1}! Please move it outside of the modeling area.'.format(str(node), str(zone)))
            raise arcpy.ExecuteError
        # Set appropriate POE values
        elif MHN.min_poe <= node <= MHN.max_poe and zone == 0:
            zoned_node[1] = node  # POE "zone" = node ID
#    return oid_array


# ---------------------------------------------------------------------
#  Create temporary (dense) road features and points of their vertices.
# ---------------------------------------------------------------------
arcpy.AddMessage('\nInitializing geodatabase...')
temp_gdb_name = 'mhn_iris_temp'
temp_gdb = os.path.join(MHN.temp_dir, temp_gdb_name + '.gdb')
if arcpy.Exists(temp_gdb):
    arcpy.Delete_management(temp_gdb)
arcpy.CreateFileGDB_management(os.path.dirname(temp_gdb), os.path.basename(temp_gdb), 'CURRENT')

# Create a layer of the modeled extent of Illinois, for clipping the MHN and IRIS links:
il_zones_sql = ''' "COUNTY" >= 17000 AND "COUNTY" < 18000 '''
illinois_lyr = MHN.make_skinny_feature_layer(MHN.zone, 'illinois_lyr', il_zones_sql)

# Select IRIS links intersecting Illinois zones
arcpy.AddMessage('Selecting IRIS links in Illinois modeling zones...')
iris_mem_fc = os.path.join(MHN.mem, 'iris')
iris_keep_fields = [iris_id_field, 'ROAD_NAME', 'MARKED_RT', 'MARKED_RT2', 'FCNAME']
iris_lyr = MHN.make_skinny_feature_layer(iris_fc, 'iris_lyr', iris_keep_fields)
arcpy.CopyFeatures_management(iris_lyr, iris_mem_fc)
iris_mem_lyr = 'iris_mem_lyr'
arcpy.MakeFeatureLayer_management(iris_mem_fc, iris_mem_lyr)
arcpy.SelectLayerByLocation_management(iris_mem_lyr, 'INTERSECT', illinois_lyr)

# Copy IRIS & MHN links into temp GDB, projecting IRIS to match MHN projection
arcpy.AddMessage('Copying IRIS & HERE links to geodatabase...')
mhn_fc = os.path.join(temp_gdb, 'mhn')
mhn_keep_fields = [mhn_id_field, 'ROADNAME', 'TYPE1']
Exemplo n.º 7
0
        '''The following nodes are referenced in {0}, but no longer exist '''
        '''in the network or are zone centroids: {1}. Please update the '''
        '''table to reference only existing, non-centroid nodes.'''
        ''.format(MHN.pnr, bad_pnr_node_str)
    )
else:
    arcpy.AddMessage('-- Park-n-Ride NODE values verified')


# -----------------------------------------------------------------------------
#  Update node/arc attributes.
# -----------------------------------------------------------------------------
# Calculate node ZONE and AREATYPE using Identity tool.
new_nodes_Z = os.path.join(MHN.mem, 'new_nodes_Z')
new_nodes_CZ = os.path.join(MHN.mem, 'new_nodes_CZ')
zone_lyr = MHN.make_skinny_feature_layer(MHN.zone, 'zone_lyr', [MHN.zone_attr])
arcpy.Identity_analysis(new_nodes, zone_lyr, new_nodes_Z, 'NO_FID')
capzone_lyr = MHN.make_skinny_feature_layer(MHN.capzone, 'capzone_lyr', [MHN.capzone_attr])
arcpy.Identity_analysis(new_nodes_Z, capzone_lyr, new_nodes_CZ, 'NO_FID')
arcpy.Delete_management(new_nodes_Z)
arcpy.DeleteIdentical_management(new_nodes_CZ, ['Shape', 'NODE'])  # Delete (arbitrarily) duplicates created from nodes lying exactly on border of 2+ zones/capzones
with arcpy.da.UpdateCursor(new_nodes_CZ, ['NODE', MHN.zone_attr, MHN.capzone_attr]) as zoned_nodes_cursor:
    for zoned_node in zoned_nodes_cursor:
        node = zoned_node[0]
        zone = zoned_node[1]
        capzone = zoned_node[2]
        if MHN.min_poe <= node <= MHN.max_poe and zone > 0:
            MHN.die('POE {0} is in zone {1}! Please move it outside of the modeling area.'.format(str(node), str(zone)))
            raise arcpy.ExecuteError
        elif MHN.min_poe <= node <= MHN.max_poe and zone == 0:
            zoned_node[1] = node
transact_attr = [hwyproj_id_field,'ACTION_CODE','NEW_DIRECTIONS','NEW_TYPE1','NEW_TYPE2','NEW_AMPM1','NEW_AMPM2','NEW_POSTEDSPEED1',
                 'NEW_POSTEDSPEED2','NEW_THRULANES1','NEW_THRULANES2','NEW_THRULANEWIDTH1','NEW_THRULANEWIDTH2','ADD_PARKLANES1',
                 'ADD_PARKLANES2','ADD_SIGIC','ADD_CLTL','ADD_RRGRADECROSS','NEW_TOLLDOLLARS','NEW_MODES','TOD','ABB','REP_ANODE','REP_BNODE']
transact_query = '''"{0}" IN ('{1}')'''.format(hwyproj_id_field, "','".join((hwyproj_id for hwyproj_id in hwy_projects)))
transact_view = in_mhn.make_skinny_table_view(in_mhn.route_systems[in_mhn.hwyproj][0], 'transact_view', transact_attr, transact_query)
in_mhn.write_attribute_csv(transact_view, transact_csv, transact_attr)
hwy_abb = in_mhn.make_attribute_dict(transact_view, 'ABB', attr_list=[])
arcpy.Delete_management(transact_view)

# Export arc & node attributes of all baselinks and skeletons used in
# projects completed by scenario year.
network_attr = ['ANODE','BNODE','ABB','DIRECTIONS','TYPE1','TYPE2','AMPM1','AMPM2','POSTEDSPEED1','POSTEDSPEED2',
                'THRULANES1','THRULANES2','THRULANEWIDTH1','THRULANEWIDTH2','PARKLANES1','PARKLANES2','BASELINK',
                'SIGIC','CLTL','RRGRADECROSS','TOLLDOLLARS','MODES','MILES']
network_query = '''"BASELINK" = '1' OR "ABB" IN ('{}')'''.format("','".join((abb for abb in hwy_abb if abb[-1] != '1')))
network_lyr = in_mhn.make_skinny_feature_layer(in_mhn.arc, 'network_lyr', network_attr, network_query)
in_mhn.write_attribute_csv(network_lyr, network_csv, network_attr)

# Process attribute tables with export_future_network_2.sas.
sas1_sas = os.path.join(in_mhn.util_dir, '{}.sas'.format(sas1_name))
sas1_args = [network_csv, transact_csv, year_csv, update_link_csv, flag_node_csv, build_year, in_mhn.max_poe, in_mhn.base_year]
in_mhn.submit_sas(sas1_sas, sas1_log, sas1_lst, sas1_args)
if not os.path.exists(sas1_log):
    in_mhn.die('{} did not run!'.format(sas1_sas))
else:
    os.remove(sas1_log)
    in_mhn.delete_if_exists(sas1_lst)
    os.remove(year_csv)
    os.remove(transact_csv)
    os.remove(network_csv)
#    return oid_array

# ---------------------------------------------------------------------
#  Create temporary (dense) road features and points of their vertices.
# ---------------------------------------------------------------------
arcpy.AddMessage('\nInitializing geodatabase...')
temp_gdb_name = 'mhn_iris_temp'
temp_gdb = os.path.join(MHN.temp_dir, temp_gdb_name + '.gdb')
if arcpy.Exists(temp_gdb):
    arcpy.Delete_management(temp_gdb)
arcpy.CreateFileGDB_management(os.path.dirname(temp_gdb),
                               os.path.basename(temp_gdb), 'CURRENT')

# Create a layer of the modeled extent of Illinois, for clipping the MHN and IRIS links:
il_zones_sql = ''' "COUNTY" >= 17000 AND "COUNTY" < 18000 '''
illinois_lyr = MHN.make_skinny_feature_layer(MHN.zone, 'illinois_lyr',
                                             il_zones_sql)

# Select IRIS links intersecting Illinois zones
arcpy.AddMessage('Selecting IRIS links in Illinois modeling zones...')
iris_mem_fc = os.path.join(MHN.mem, 'iris')
iris_keep_fields = [
    iris_id_field, 'ROAD_NAME', 'MARKED_RT', 'MARKED_RT2', 'FCNAME',
    'INVENTORY', 'BEG_STA', 'END_STA'
]
iris_lyr = MHN.make_skinny_feature_layer(iris_fc, 'iris_lyr', iris_keep_fields)
arcpy.CopyFeatures_management(iris_lyr, iris_mem_fc)
iris_mem_lyr = 'iris_mem_lyr'
arcpy.MakeFeatureLayer_management(iris_mem_fc, iris_mem_lyr)
arcpy.SelectLayerByLocation_management(iris_mem_lyr, 'INTERSECT', illinois_lyr)

# Copy IRIS & MHN links into temp GDB, projecting IRIS to match MHN projection
Exemplo n.º 10
0
    bad_pnr_node_str = ', '.join((str(n) for n in sorted(bad_pnr_nodes)))
    MHN.die(
        '''The following nodes are referenced in {0}, but no longer exist '''
        '''in the network or are zone centroids: {1}. Please update the '''
        '''table to reference only existing, non-centroid nodes.'''
        ''.format(MHN.pnr, bad_pnr_node_str))
else:
    arcpy.AddMessage('-- Park-n-Ride NODE values verified')

# -----------------------------------------------------------------------------
#  Update node/arc attributes.
# -----------------------------------------------------------------------------
# Calculate node ZONE and AREATYPE using Identity tool.
new_nodes_CZ = os.path.join(MHN.mem, 'new_nodes_CZ')
subzone_lyr = MHN.make_skinny_feature_layer(
    MHN.subzone, 'subzone_lyr',
    [MHN.zone_attr, MHN.subzone_attr, MHN.capzone_attr])
arcpy.Identity_analysis(new_nodes, subzone_lyr, new_nodes_CZ, 'NO_FID')

arcpy.DeleteIdentical_management(
    new_nodes_CZ, ['Shape', 'NODE']
)  # Delete (arbitrarily) duplicates created from nodes lying exactly on border of 2+ zones/capzones
with arcpy.da.UpdateCursor(
        new_nodes_CZ,
    ['NODE', MHN.zone_attr, MHN.subzone_attr, MHN.capzone_attr
     ]) as zoned_nodes_cursor:
    for zoned_node in zoned_nodes_cursor:
        node = zoned_node[0]
        zone = zoned_node[1]
        subzone = zoned_node[2]
        capzone = zoned_node[3]