Example Data ¶
Example data can be found in the /examples
directory.
Name | Category | Notes |
---|---|---|
Blue Line Service Enhancement A | Transit Property Change | changes headway for a single trip during the morning peak |
Remove Am Service On The Green Line | Transit Service Deletion | |
Example True Geometry | Pycode | |
Convert Intersection To Interchange | Multiple: Roadway Addition, Roadway Deletion | demonstrates how to nest multiple changes into a single project under changes |
Example Calculate Mega Freeways | Pycode | |
Example Delete Roadway | Roadway Deletion | simple roadway deletion |
Example Property Change For All Links | Roadway Property Change | Reduce lanes and add separated bike facility for all drive links with two lanes and bicycle facility of 0,2, or 3 |
Example Roadway Add | Roadway Addition | Simple project card to add new roadway |
Bus Resign | Transit Property Change | |
Change Node X Value Location | Roadway Property Change | |
Bus Reroute | Transit Routing Change | re-routes a bus route to avoid construction |
Example Add Simple Managed Lane Project | Roadway Property Change | Simple managed lane project with AM and PM lanes are tolled based on occupancy |
Example Roadway Addition And Deletion | Multiple: Roadway Addition, Roadway Deletion | project card with multiple category of add and delete changes |
Example I394 Parallel Lanes | Roadway Property Change | demonstrates how to add managed lanes to an existing roadway with restricted access |
New Green Transit | Transit Route Addition | |
Example Property Change | Roadway Property Change | Simple road diet |
Cards ¶
Blue Line Service Enhancement A ¶
Category: Transit Property Change
examples/transit-property-change.yml
project: Blue Line Service Enhancement A
notes: changes headway for a single trip during the morning peak
tags:
- example
transit_property_change:
service:
trip_properties:
trip_id:
- 14940701-JUN19-MVS-BUS-Weekday-01
timespans:
- ['06:00:00', '09:00:00']
property_changes:
headway_secs:
set: 900
Remove Am Service On The Green Line ¶
Category: Transit Service Deletion
examples/transit-service_deletion.yml
project: Remove AM service on the Green Line
transit_service_deletion:
service:
trip_properties:
route_short_name: "green"
timespans:
- ['06:00:00', '09:00:00']
clean_shapes: false
clean_routes: true
Example True Geometry ¶
Category: Pycode
examples/roadway-new-geometry.wrangler
---
project: example true geometry
tags: []
dependencies: {}
self_obj_type: RoadwayNetwork
note: ''
category: Calculated Roadway
---
# this is an example wrangler card to implement Option C dicussed in this issue:
# https://github.com/network-wrangler/projectcard/issues/15
# users will supply two shapefiles, both includes model_link_id and geometry
# the only difference they are trying to capture is the geometry for some links
import geopandas as gpd
import pandas as pd
import copy
from network_wrangler.utils.ids import create_str_int_combo_ids
## UPDATE HERE: in case the link id in the input .shp is not called model_link_id
UNIQUE_INPUT_LINK_ID_KEY = "link_id"
UNIQUE_SHAPE_KEY = "shape_id"
## copy the link and shape attrs in case any dataframe changes remove these attrs
links_attrs = copy.deepcopy(self.links_df.attrs)
shapes_attrs = copy.deepcopy(self.shapes_df.attrs)
########
# INPUTS
########
# read input geometry file supplied by user, can be shapefiles, geojsons
## UPDATE HERE: shapefile 1
## this is the link .shp before user changes any geometry
links_gdf = gpd.read_file("BaseLinks_head2.shp")
## UPDATE HERE: shapefile 2
## this is the link .shp after user changes any geometry
links_geometry_gdf = gpd.read_file("BaseLinks_head2_geometry_changes.shp")
## set index
links_gdf = links_gdf.set_index(UNIQUE_INPUT_LINK_ID_KEY).sort_index()
links_geometry_gdf = links_geometry_gdf.set_index(UNIQUE_INPUT_LINK_ID_KEY).sort_index()
## checking consistency
## check the two input shapefiles are of the same length
assert len(links_gdf)==len(links_geometry_gdf), "the two input files have different length"
## check the two input shapefiles have the same index, ignore sequence
assert links_gdf.index.equals(links_geometry_gdf.index), "the two input files have different links"
#########
# PROCESS
#########
# convert the two input files to the same CRS as the base network
links_gdf = links_gdf.to_crs("epsg:4269")
links_geometry_gdf = links_geometry_gdf.to_crs("epsg:4269")
# find links with different geometry
new_geometry_gdf = links_geometry_gdf[~links_geometry_gdf.geom_equals(links_gdf)]
# create unique shape hash for new geometry
new_geometry_gdf[UNIQUE_SHAPE_KEY] = create_str_int_combo_ids(
len(new_geometry_gdf), self.shapes_df[UNIQUE_SHAPE_KEY]
)
# reset the index and rename it as "model_link_id"
new_geometry_gdf = new_geometry_gdf.reset_index().rename(columns={UNIQUE_INPUT_LINK_ID_KEY: "model_link_id"})
# overwrite the base network with the new geometry, if it exists
self.links_df = self.links_df.set_index('model_link_id')
new_geometry_gdf = new_geometry_gdf.set_index('model_link_id')
# replace the geometry, and unique shape hash
self.links_df['geometry'].update(new_geometry_gdf['geometry'])
self.links_df[UNIQUE_SHAPE_KEY].update(new_geometry_gdf[UNIQUE_SHAPE_KEY])
# reset and drop the index
self.links_df = self.links_df.reset_index()
assert "model_link_id" in self.links_df.columns
new_geometry_gdf = new_geometry_gdf.reset_index()
# add the new shape records to shapes
new_geometry_gdf = new_geometry_gdf.to_crs(self.shapes_df.crs)
self.shapes_df = pd.concat(
[self.shapes_df, new_geometry_gdf[[UNIQUE_SHAPE_KEY, "geometry"]]]
)
# drop duplicate unique shape id, keep last
self.shapes_df = self.shapes_df.drop_duplicates(subset=[UNIQUE_SHAPE_KEY], keep='last')
# make sure the attrs stay the same
self.links_df.attrs = links_attrs
self.shapes_df.attrs = shapes_attrs
Convert Intersection To Interchange ¶
Category: Multiple: Roadway Addition, Roadway Deletion
examples/roadway-add-interchange.yml
project: convert intersection to interchange
notes: demonstrates how to nest multiple changes into a single project under `changes`
changes:
- roadway_deletion:
links:
model_link_id:
- 2171
- 25856
- 383747
- 383790
- roadway_addition:
links:
- A: 354386
name: interchange ramp
roadway: motorway_link
B: 16214
distance : 0.13201
lanes: 1
model_link_id: 2171
bus_only: 0
rail_only: 0
bike_access: 0
drive_access: 1
walk_access: 0
- A: 16214
name: interchange ramp
roadway: motorway_link
B: 354386
distance: 0.13201
lanes: 1
model_link_id: 25856
bike_access: 0
drive_access: 1
walk_access: 0
- A: 4336
name: interchange ramp
roadway: motorway_link
B: 354387
distance: 0.14848
lanes: 1
model_link_id: 2171
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354387
name: interchange ramp
roadway: motorway_link
B: 354386
distance: 0.10981
lanes: 1
model_link_id: 2171
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354386
name: interchange ramp
roadway: motorway_link
B: 354387
distance: 0.10981
lanes: 1
model_link_id: 25856
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354387
name: interchange ramp
roadway: motorway_link
B: 4336
distance: 0.14848
lanes: 1
model_link_id: 25856
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354388
name: interchange ramp
roadway: motorway_link
B: 13931
distance: 0.55987
lanes: 2
model_link_id: 383747
bike_access: 0
drive_access: 1
walk_access: 0
- A: 12590
name: interchange ramp
roadway: motorway_link
count_AM: 0
B: 354389
distance: 0.15228
lanes: 2
model_link_id: 383747
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354389
name: interchange ramp
roadway: motorway_link
B: 354388
distance: 0.16071
lanes: 2
model_link_id: 383747
bike_access: 0
drive_access: 1
walk_access: 0
- A: 12655
name: interchange ramp
roadway: motorway_link
B: 354390
distance: 0.21899
lanes: 3
model_link_id: 383790
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354390
name: interchange ramp
roadway: motorway_link
B: 354391
distance: 0.21108
lanes: 3
model_link_id: 383790
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354391
B: 14248
name: interchange ramp
roadway: motorway_link
distance: 0.36316
lanes: 3
model_link_id: 383790
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354387
name: interchange ramp
roadway: motorway_link
B: 354388
distance: 0.09188
lanes: 2
model_link_id: 384040
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354390
name: interchange ramp
roadway: motorway_link
B: 354386
distance: 0.12286
lanes: 2
model_link_id: 384040
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354386
name: interchange ramp
roadway: motorway_link
B: 354391
distance: 0.08689
lanes: 2
model_link_id: 384040
bike_access: 0
drive_access: 1
walk_access: 0
- A: 354389
B: 354387
name: interchange ramp
roadway: motorway_link
distance: 0.09431
lanes: 2
model_link_id: 384040
bike_access: 0
drive_access: 1
walk_access: 0
nodes:
- X: -93.14412
Y: 44.87497
model_node_id: 354386
- X: -93.14189
Y: 44.87499
model_node_id: 354387
- X: -93.14239
Y: 44.87644
model_node_id: 354388
- X: -93.14322
Y: 44.87414
model_node_id: 354389
- X: -93.14273
Y: 44.87648
model_node_id: 354390
- X: -93.14382
Y: 44.87355
model_node_id: 354391
Example Calculate Mega Freeways ¶
Category: Pycode
examples/roadway-calculated.wr
---
project: example calculate mega freeways
self_obj_type: RoadwayNetwork
---
self.links_df.loc[self.links_df['lanes'] == 4, 'lanes'] = 12
Example Delete Roadway ¶
Category: Roadway Deletion
examples/roadway-delete.yml
project: example delete roadway
notes: simple roadway deletion
tags:
- 'delete roadway'
- 'example'
roadway_deletion:
links:
model_link_id:
- 281
- 477533
nodes:
model_node_id:
- 314159
Example Property Change For All Links ¶
Category: Roadway Property Change
examples/roadway-property-change-all.yml
project: Example property change for all links
tags:
- 'example'
roadway_property_change:
facility:
links:
modes: ['drive']
all: true
lanes: 2
bicycle_facility: [0,2,3]
property_changes:
lanes:
set: 1
bicycle_facility:
set: 1
notes: Reduce lanes and add separated bike facility for all drive links with two lanes and bicycle facility of 0,2, or 3
Example Roadway Add ¶
Category: Roadway Addition
examples/roadway-add.yml
project: example roadway add
notes: Simple project card to add new roadway
tags:
- 'add roadway'
- 'example'
roadway_addition:
links:
- A: 269066
B: 268932
name: new neighborhood st
bike_access: 1
drive_access: 0
bus_only: 0
rail_only: 0
walk_access: 1
roadway: residential
lanes: 1
model_link_id: 404982
- A: 268932
B: 269066
bike_access: 1
name: new neighborhood st
drive_access: 0
bus_only: 0
rail_only: 0
walk_access: 1
roadway: residential
lanes: 1
model_link_id: 407042
Bus Resign ¶
Category: Transit Property Change
examples/transit-node-selection.yml
project: Bus resign
tags:
- existing_plus_committed
transit_property_change:
service:
trip_properties:
route_id:
- "294-111"
nodes:
model_node_id:
- 37582
- 37574
require: "any"
property_changes:
trip_headsign:
change: " thru Union Station"
Change Node X Value Location ¶
Category: Roadway Property Change
examples/roadway-node-property-change.yml
project: Change node X value location
roadway_property_change:
facility:
nodes:
model_node_id: [1234]
property_changes:
X:
set: 1.0
Bus Reroute ¶
Category: Transit Routing Change
examples/transit-shape-change.yml
project: Bus Reroute
notes: re-routes a bus route to avoid construction
tags:
- existing_plus_committed
transit_routing_change:
service:
trip_properties:
route_id:
- 294-111
direction_id: 1
routing:
existing:
- -37582
- -37574
- -4761
- -4763
- -4764
- -98429
- 45985
- -57483
- -126324
- -57484
- 150855
- -11188
- 84899
- 46666
- -77077
set:
- -37582
- -37574
- -4761
- -4763
- -4764
- -98429
- 45985
- -57483
- -126324
- -57484
- 150855
- -11188
- 84899
- 46666
- -46665
- -46663
- -81820
- -76167
- -77077
Example Add Simple Managed Lane Project ¶
Category: Roadway Property Change
examples/roadway-add-managed-lane-simple.yml
project: example add simple managed lane project
notes: Simple managed lane project with AM and PM lanes are tolled based on occupancy
tags:
- 'example'
- 'managed'
roadway_property_change:
facility:
links:
name:
- 'I 35E'
from:
osm_node_id: '961117623'
to:
osm_node_id: '2564047368'
property_changes:
segment_id:
set: 35EHOT-A
lanes:
set: 3
scoped:
- timespan: ['6:00', '9:00']
set: 2
- timespan: ['16:00', '19:00']
set: 2
ML_lanes:
set: 0
scoped:
- timespan: ['6:00', '9:00']
set: 1
- timespan: ['16:00', '19:00']
set: 1
ML_price:
set: 0
overwrite_scoped: "all"
scoped:
- timespan: ['6:00', '9:00']
category: ['sov']
set: 1.5
- timespan: ['16:00', '19:00']
category: ['sov']
set: 2.5
- timespan: ['6:00', '9:00']
category: ['hov2']
set: 1.0
- timespan: ['16:00', '19:00']
category: ['hov2']
set: 2.0
ML_access_point:
set: 'all'
ML_egress_point:
set: 'all'
Example Roadway Addition And Deletion ¶
Category: Multiple: Roadway Addition, Roadway Deletion
examples/roadway-add-delete.yml
project: example roadway addition and deletion
tags:
- 'add and delete roadway'
changes:
- roadway_addition:
nodes:
- model_node_id: 314159
X: -93.18389
Y: 44.96898
drive_node: 1
walk_node: 0
bike_node: 0
transit_node: 1
- roadway_deletion:
links:
model_link_id:
- 281
- 477533
nodes:
model_node_id:
- 314159
- roadway_addition:
links:
- A: 3230
B: 3262
model_link_id: 999998
trn_priority: 0
lanes: 1
name: new bike greenway and neighborhood st
bike_facility: 3
drive_access: 1
walk_access: 1
bike_access: 1
bus_only: 0
rail_only: 0
roadway: residential
distance: 0.10462
ttime_assert: 0.0
OPERATION_final: A
- A: 3262
B: 3230
model_link_id: 999997
trn_priority: 0
lanes: 1
name: new bike greenway and neighborhood st
bike_facility: 3
drive_access: 1
walk_access: 1
bike_access: 1
bus_only: 0
rail_only: 0
roadway: residential
distance: 0.10462
ttime_assert: 0.0
OPERATION_final: A
nodes:
- model_node_id: 354388
X: -93.18389
Y: 44.96898
drive_node: 1
walk_node: 0
bike_node: 0
transit_node: 1
notes: project card with multiple category of add and delete changes
Example I394 Parallel Lanes ¶
Category: Roadway Property Change
examples/roadway-add-managed-lane-restricted-access.yml
project: Example I394 Parallel Lanes
tags: ['managed lanes']
notes: demonstrates how to add managed lanes to an existing roadway with restricted access
roadway_property_change:
facility:
links:
model_link_id:
- 390239
- 391206
- 390344
- 401484
property_changes:
ML_lanes:
set: 0
scoped:
- timespan: ['6:00', '9:00']
set: 1
overwrite_conflicts: true
- timespan: ['15:00', '18:00']
set: 1
lanes:
change: 0
scoped:
- timespan: ['6:00', '9:00']
change: -1
- timespan: ['15:00', '18:00']
change: -1
segment_id:
set: 5
ML_HOV:
set: 5
HOV:
set: 5
ML_access_point:
set: [38765, 87982]
ML_egress_point:
set: [87993, 37457]
New Green Transit ¶
Category: Transit Route Addition
examples/transit-route_addition.yml
project: New Green Transit
tags:
- new transit
transit_route_addition:
routes:
- route_id: abc
route_long_name: green_line
route_short_name: green
route_type: 3
agency_id: The Bus
trips:
- direction_id: 0
headway_secs:
- ('6:00','12:00'): 600
- ('12:00','13:00'): 900
routing:
- 1:
stop: true #when stop is set to True, defaults to allow both boarding and alighting
- 2
- 3
- 4:
stop: true # default to False, specify only when stopping
alight: false # default to True, specify only when not default
- 5
- 6:
stop: true
- direction_id: 1
headway_secs:
- ('6:00','12:00'): 600
- ('12:00','13:00'): 900
routing:
- 6:
stop: true
- 5:
stop: true
dwell_sec: 30
- 4:
stop: true
- 6
- 3:
time_to_next_node_sec: 90
- 2:
stop: true
- 1:
stop: true
Example Property Change ¶
Category: Roadway Property Change
examples/roadway-property-change.yml
project: Example property change
tags:
- 'example'
roadway_property_change:
facility:
links:
modes: ['drive','bike']
osm_link_id:
- '1234'
- '2345'
from:
osm_node_id: '4321'
to:
osm_node_id: '4322'
property_changes:
lanes:
existing: 3
change: -1
existing_value_conflict: error
bicycle_facility:
existing: 1
set: 3
existing_value_conflict: skip
notes: Simple road diet