Networks ¶
Roadway Network Format ¶
RoadwayNetworks must be defined in the following format, which leverages Open Street Map which uses a tag-based format (e.g. json, xml). This may be changed in the future to align with the tabular-based General Modeling Network Specification.
A network is defined by a set of nodes and links which connect them. Shapes may be optionally specified for each link in a separate file.
file serialization formats
While the default serialiation for roadway networks is json
/geojson
and for transit data is csv
, networks can also be stored – more efficiently – in parquet files with a similar structure. Other workable file serializations include shapefiles, csvs, and anything that can be read by pandas or geopandas. This can be noted in most I/O procedures by including the keyword argument file_format = <format>
.
Roadway Validation ¶
RoadwayNetworks can be validated using the following tools:
network_directory
: The roadway network file directory.file_format
: The suffices of roadway network file name.-s
,--strict
: Validate the roadway network strictly without parsing and filling in data.--output_dir
: The output directory for the validation report.
from network_wrangler.roadway.validate import validate_roadway_in_dir
validate_roadway_in_dir(
directory=<network_directory>,
file_format=<file_format>,
strict=<strict_bool>>,
output_dir=<output_dir>
)
network_directory
: The roadway network file directory.file_format
: The suffices of roadway network file name.strict
: Validate the roadway network strictly without parsing and filling in data.output_dir
: The output directory for the validation report.
Examples ¶
Network Wrangler is packaged with two examples located in the /examples
directory:
- St Paul, MN
- Small which is a several block exerpt of St Paul and is infinitely easier to trouble-shoot quickly.
Road Nodes ¶
A valid geojson
, shp
, or parquet
file.
Datamodel used to validate if links_df is of correct format and types.
Must have a record for each node used by the links
table and by the transit shapes
, stop_times
, and stops
tables.
Attributes:
Name | Type | Description |
---|---|---|
model_node_id |
int
|
Unique identifier for the node. |
osm_node_id |
Optional[str]
|
Reference to open street map node id. Used for querying. Not guaranteed to be unique. |
X |
float
|
Longitude of the node in WGS84. Must be in the range of -180 to 180. |
Y |
float
|
Latitude of the node in WGS84. Must be in the range of -90 to 90. |
geometry |
GeoSeries
|
Warning: this attribute is controlled by wrangler and should not be explicitly user-edited. |
Source code in network_wrangler/models/roadway/tables.py
Road Links ¶
A valid geojson
, shp
, parquet
, or json
file.
Datamodel used to validate if links_df is of correct format and types.
Attributes:
Name | Type | Description |
---|---|---|
model_link_id |
int
|
Unique identifier for the link. |
A |
int
|
|
B |
int
|
|
geometry |
GeoSeries
|
Warning: this attribute is controlled by wrangler and should not be explicitly user-edited. Simple A→B geometry of the link. |
name |
str
|
Name of the link. |
rail_only |
bool
|
If the link is only for rail. Default is False. |
bus_only |
bool
|
If the link is only for buses. Default is False. |
drive_access |
bool
|
If the link allows driving. Default is True. |
bike_access |
bool
|
If the link allows biking. Default is True. |
walk_access |
bool
|
If the link allows walking. Default is True. |
truck_access |
bool
|
If the link allows trucks. Default is True. |
distance |
float
|
Length of the link. |
roadway |
str
|
Type of roadway per OSM definitions. Default is “road”. |
projects |
str
|
Warning: this attribute is controlled by wrangler and should not be explicitly user-edited. Comma-separated list of project names applied to the link. Default is “”. |
managed |
int
|
Warning: this attribute is controlled by wrangler and should not be explicitly user-edited. Indicator for the type of managed lane facility. Values can be:
|
shape_id |
str
|
Identifier referencing the primary key of the shapes table. Default is None. |
lanes |
int
|
Default number of lanes on the link. Default is 1. |
sc_lanes |
Optional[list[dict]]
|
List of scoped link values for the number of lanes. Default is None.
Example: |
price |
float
|
Default price to use the link. Default is 0. |
sc_price |
Optional[list[dict]]
|
List of scoped link values for the price. Default is None.
Example: |
ref |
Optional[str]
|
Reference numbers for link referring to a route or exit number per the OSM definition. Default is None. |
access |
Optional[Any]
|
User-defined method to note access restrictions for the link. Default is None. |
ML_projects |
Optional[str]
|
Warning: this attribute is controlled by wrangler and should not be explicitly user-edited. Comma-separated list of project names applied to the managed lane. Default is “”. |
ML_lanes |
Optional[int]
|
Default number of lanes on the managed lane. Default is None. |
ML_price |
Optional[float]
|
Default price to use the managed lane. Default is 0. |
ML_access |
Optional[Any]
|
User-defined method to note access restrictions for the managed lane. Default is None. |
ML_access_point |
Optional[bool]
|
If the link is an access point for the managed lane. Default is False. |
ML_egress_point |
Optional[bool]
|
If the link is an egress point for the managed lane. Default is False. |
sc_ML_lanes |
Optional[list[dict]]
|
List of scoped link values for the number of lanes on the managed lane. Default is None. |
sc_ML_price |
Optional[list[dict]]
|
List of scoped link values for the price of the managed lane. Default is None. |
sc_ML_access |
Optional[list[dict]]
|
List of scoped link values for the access restrictions of the managed lane. Default is None. |
ML_geometry |
Optional[GeoSeries]
|
Warning: this attribute is controlled by wrangler and should not be explicitly user-edited. Simple A→B geometry of the managed lane. Default is None. |
ML_shape_id |
Optional[str]
|
Identifier referencing the primary key of the shapes table for the managed lane. Default is None. |
osm_link_id |
Optional[str]
|
Identifier referencing the OSM link ID. Default is “”. |
GP_A |
Optional[int]
|
Warning: this attribute is controlled by wrangler and should not be explicitly user-edited. Identifier referencing the primary key of the associated general purpose link start node for a managed lane link in a model network. Default is None. |
GP_B |
Optional[int]
|
Warning: this attribute is controlled by wrangler and should not be explicitly user-edited. Identifier referencing the primary key of the associated general purpose link end node for a managed lane link in a model network. Default is None. |
User Defined Properties
Additional properites may be defined and are assumed to have the same definition of OpenStreetMap if they have overlapping property names.
Properties for parallel managed lanes ¶
Properties for parallel managed lanes are prefixed with ML_
. (Almost) any property,
including an ad-hoc one, can be made to apply to a parallel managed lane by applying
the prefix ML_
, e.g. ML_lanes
Warning
The following properties should not be assigned an ML_
prefix by the user
because they are assigned one within networkwrangler:
name
A
B
model_link_id
Time- or category-dependent properties ¶
The following properties can be time-dependent, category-dependent, or both by adding sc_
.
The “plain” property without the prefix becomes the default when no scoped property applies.
Property | # of Lanes | Price |
---|---|---|
Default value | lanes |
price |
Time- and/or category-dependent value | sc_lanes |
sc_price |
Default value for managed lane | ML_lanes |
ML_price |
Time- and/or category-dependent value for managed lane | sc_ML_lanes |
sc_ML_price |
previous format for scoped properties
Some previous tooling was developed around a previous method for serializing scoped properties. In order to retain compatability with this format:
load_roadway_from_dir()
,read_links()
, and associated functions will “sniff” the network for the old format and apply the converter functiontranslate_links_df_v0_to_v1()
write_links()
has an boolean attribute toconvert_complex_properties_to_single_field
which can also be invoked fromwrite_roadway()
asconvert_complex_link_properties_to_single_field
.
Defining time-dependent properties ¶
Time-dependent properties are defined as a list of dictionaries with timespans and values.
- Timespans must be defined as a list of HH:MM or HH:MM:SS using a 24-hour clock:
('06:00':'09:00')
. - Timespans must not intersect.
Time-dependent property
$3 peak-period pricing
Defining time- and category-dependent properties ¶
Properties co-dependent on time- and category are defined as a list of dictionaries with value, category and time defined.
time- and category-dependent property
A pricing strategy which only applies in peak period for trucks and sovs:
Tip
There is no limit on other, user-defined properties being listed as time-dependent or time- and category-dependent.
User-defined variable by time of day
Define a variable access
to represent which categories can access the network and vary it by time of day.
Source code in network_wrangler/models/roadway/tables.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
Road Shapes ¶
A valid geojson
, shp
, or parquet
file with LineString
geometry features and the folowing properties
.
Datamodel used to validate if shapes_df is of correct format and types.
Should have a record for each shape_id
referenced in links
table.
Attributes:
Name | Type | Description |
---|---|---|
shape_id |
str
|
Unique identifier for the shape. |
geometry |
GeoSeries
|
Warning: this attribute is controlled by wrangler and should not be explicitly user-edited. Geometry of the shape. |
ref_shape_id |
Optional[str]
|
Reference to another |
Source code in network_wrangler/models/roadway/tables.py
Transit Network Format ¶
Data models for various GTFS tables using pandera library.
The module includes the following classes:
- AgencyTable: Optional. Represents the Agency table in the GTFS dataset.
- WranglerStopsTable: Represents the Stops table in the GTFS dataset.
- RoutesTable: Represents the Routes table in the GTFS dataset.
- WranglerShapesTable: Represents the Shapes table in the GTFS dataset.
- WranglerStopTimesTable: Represents the Stop Times table in the GTFS dataset.
- WranglerTripsTable: Represents the Trips table in the GTFS dataset.
Each table model leverages the Pydantic data models defined in the records module to define the data model for the corresponding table. The classes also include additional configurations for, such as uniqueness constraints.
Validating a table to the WranglerStopsTable
Transit Networks must use the the GTFS Schedule format with the following additional constraints:
- At this time, only frequency-based schedules are supported.
- Each
stop_id
must be a node in the RoadwayNetwork. shapes.txt
is required (it is optional in GTFS) and must have the added fieldmodel_node_id
associating a specific location with a node on theRoadwayNetwork
.
Stops ¶
Wrangler flavor of GTFS StopsTable.
For field definitions, see the GTFS reference: https://gtfs.org/documentation/schedule/reference/#stopstxt
Attributes:
Name | Type | Description |
---|---|---|
stop_id |
int
|
The stop_id. Primary key. Required to be unique. Wrangler assumes that this is a reference to a roadway node and as such must be an integer |
stop_lat |
float
|
The stop latitude. |
stop_lon |
float
|
The stop longitude. |
wheelchair_boarding |
Optional[int]
|
The wheelchair boarding. |
stop_code |
Optional[str]
|
The stop code. |
stop_name |
Optional[str]
|
The stop name. |
tts_stop_name |
Optional[str]
|
The text-to-speech stop name. |
stop_desc |
Optional[str]
|
The stop description. |
zone_id |
Optional[str]
|
The zone id. |
stop_url |
Optional[str]
|
The stop URL. |
location_type |
Optional[LocationType]
|
The location type. Values can be: - 0: stop platform - 1: station - 2: entrance/exit - 3: generic node - 4: boarding area Default of blank assumes a stop platform. |
parent_station |
Optional[int]
|
The |
stop_timezone |
Optional[str]
|
The stop timezone. |
stop_id_GTFS |
Optional[str]
|
The stop_id from the GTFS data. |
projects |
str
|
A comma-separated string value for projects that have been applied to this stop. |
Source code in network_wrangler/models/gtfs/tables.py
Routes ¶
Represents the Routes table in the GTFS dataset.
For field definitions, see the GTFS reference: https://gtfs.org/documentation/schedule/reference/#routestxt
Attributes:
Name | Type | Description |
---|---|---|
route_id |
str
|
The route_id. Primary key. Required to be unique. |
route_short_name |
Optional[str]
|
The route short name. |
route_long_name |
Optional[str]
|
The route long name. |
route_type |
RouteType
|
The route type. Required. Values can be: - 0: Tram, Streetcar, Light rail - 1: Subway, Metro - 2: Rail - 3: Bus |
agency_id |
Optional[str]
|
The agency_id. Foreign key to agency_id in the agencies table. |
route_desc |
Optional[str]
|
The route description. |
route_url |
Optional[str]
|
The route URL. |
route_color |
Optional[str]
|
The route color. |
route_text_color |
Optional[str]
|
The route text color. |
Source code in network_wrangler/models/gtfs/tables.py
Trips ¶
Represents the Trips table in the Wrangler feed, adding projects list.
For field definitions, see the GTFS reference: https://gtfs.org/documentation/schedule/reference/#tripstxt
Attributes:
Name | Type | Description |
---|---|---|
trip_id |
str
|
Primary key. Required to be unique. |
shape_id |
str
|
Foreign key to |
direction_id |
DirectionID
|
The direction id. Required. Values can be: - 0: Outbound - 1: Inbound |
service_id |
str
|
The service id. |
route_id |
str
|
The route id. Foreign key to |
trip_short_name |
Optional[str]
|
The trip short name. |
trip_headsign |
Optional[str]
|
The trip headsign. |
block_id |
Optional[str]
|
The block id. |
wheelchair_accessible |
Optional[int]
|
The wheelchair accessible. Values can be: - 0: No information - 1: Allowed - 2: Not allowed |
bikes_allowed |
Optional[int]
|
The bikes allowed. Values can be: - 0: No information - 1: Allowed - 2: Not allowed |
projects |
str
|
A comma-separated string value for projects that have been applied to this trip. |
Source code in network_wrangler/models/gtfs/tables.py
Stop_times ¶
Wrangler flavor of GTFS StopTimesTable.
For field definitions, see the GTFS reference: https://gtfs.org/documentation/schedule/reference/#stop_timestxt
The primary key of this table is a composite key of trip_id
and stop_sequence
.
Attributes:
Name | Type | Description |
---|---|---|
trip_id |
str
|
Foreign key to |
stop_id |
int
|
Foreign key to |
stop_sequence |
int
|
The stop sequence. |
pickup_type |
PickupDropoffType
|
The pickup type. Values can be: - 0: Regularly scheduled pickup - 1: No pickup available - 2: Must phone agency to arrange pickup - 3: Must coordinate with driver to arrange pickup |
drop_off_type |
PickupDropoffType
|
The drop off type. Values can be: - 0: Regularly scheduled drop off - 1: No drop off available - 2: Must phone agency to arrange drop off - 3: Must coordinate with driver to arrange drop off |
arrival_time |
datetime
|
The arrival time in datetime format. |
departure_time |
datetime
|
The departure time in datetime format. |
shape_dist_traveled |
Optional[float]
|
The shape distance traveled. |
timepoint |
Optional[TimepointType]
|
The timepoint type. Values can be: - 0: The stop is not a timepoint - 1: The stop is a timepoint |
projects |
str
|
A comma-separated string value for projects that have been applied to this stop. |
Source code in network_wrangler/models/gtfs/tables.py
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
|
Shapes ¶
Wrangler flavor of GTFS ShapesTable.
For field definitions, see the GTFS reference: https://gtfs.org/documentation/schedule/reference/#shapestxt
Attributes:
Name | Type | Description |
---|---|---|
shape_id |
str
|
The shape_id. Primary key. Required to be unique. |
shape_pt_lat |
float
|
The shape point latitude. |
shape_pt_lon |
float
|
The shape point longitude. |
shape_pt_sequence |
int
|
The shape point sequence. |
shape_dist_traveled |
Optional[float]
|
The shape distance traveled. |
shape_model_node_id |
int
|
The model_node_id of the shape point. Foreign key to the model_node_id in the nodes table. |
projects |
str
|
A comma-separated string value for projects that have been applied to this shape. |
Source code in network_wrangler/models/gtfs/tables.py
Frequencies ¶
Wrangler flavor of GTFS FrequenciesTable.
For field definitions, see the GTFS reference: https://gtfs.org/documentation/schedule/reference/#frequenciestxt
The primary key of this table is a composite key of trip_id
and start_time
.
Attributes:
Name | Type | Description |
---|---|---|
trip_id |
str
|
Foreign key to |
start_time |
datetime
|
The start time in datetime format. |
end_time |
datetime
|
The end time in datetime format. |
headway_secs |
int
|
The headway in seconds. |
Source code in network_wrangler/models/gtfs/tables.py
Agencies ¶
Represents the Agency table in the GTFS dataset.
For field definitions, see the GTFS reference: https://gtfs.org/documentation/schedule/reference/#agencytxt
Attributes:
Name | Type | Description |
---|---|---|
agency_id |
str
|
The agency_id. Primary key. Required to be unique. |
agency_name |
str
|
The agency name. |
agency_url |
str
|
The agency URL. |
agency_timezone |
str
|
The agency timezone. |
agency_lang |
str
|
The agency language. |
agency_phone |
str
|
The agency phone number. |
agency_fare_url |
str
|
The agency fare URL. |
agency_email |
str
|
The agency email. |
Source code in network_wrangler/models/gtfs/tables.py
Transit Validation ¶
TransitNetworks can be validated using the following tools:
python validate_transit.py <network_dir> <file_format> [-s] [--output_dir <output_dir>] [--road_dir <road_dir>] [--road_file_format <road_file_format]
network_dir
: The transit network file directory.file_format
: The suffices of transit network .--output_dir
: The output directory for the validation report.--road_dir
: The directory roadway network. if want to validate the transit network to it.--road_file_format
: The file format for roadway network. Defaults to ‘geojson’.
from network_wrangler.transit.validate import validate_transit_in_dir
validate_transit_in_dir(
dir=<network_dir>,
file_format=<network_file_format>,
road_dir=<road_dir>,
road_file_format=<road_file_format,
)
network_dir
: The roadway network file directory.network_file_format
: The file format of the transit files.road_dir
: The directory roadway network. if want to validate the transit network to it.road_file_format
: The file format for roadway network. Defaults to ‘geojson’.
Project Cards ¶
Project Cards, which define changes to the roadway and transit networks must use the ProjectCard standard.
Model Roadway Network Export Format ¶
In order to separately calculate the delay when the networks are assigned in static roadway network assignment the roadway network must be exported with separate managed lane links.
To acheive this, RoadwayNetwork objects have the option to be exported in the ModelRoadwayNetwork format, which separates a link into two: set of managed lanes and a set of general purpose lanes which are connected by a set of dummy connector links.
Managed Lane Links ¶
All properties preceded by ML_
will be copied, without that prefix, to the managed lane links.
The following are controlled by parameters which can be set using WranglerConfig:
Geometry of managed lanes will be defined as a shape offset by the parameter ML_OFFSET_METERS
.
Properties defined in the parameter ADDITIONAL_COPY_FROM_GP_TO_ML
are also copied from the parent link.
New model_node_id
s and model_link_ids
are generated based either on ranges or using a scalar from the GP link based on: ML_LINK_ID_METHOD
, ML_NODE_ID_METHOD
, ML_LINK_ID_RANGE
, ML_NODE_ID_RANGE
, ML_LINK_ID_SCALAR
, ML_NODE_ID_SCALAR
name
is created as “managed lane of name of GP link
“
Relationship to the general purpose lanes is retained using the fields GP_A
, GP_B
, GP_model_link_id
.
Managed-lane link-ids are generated as multiples of 10.
Dummy Connector Links ¶
Dummy connector links are generated between the general purpose lane links and managed lane links at points defined by the variable ML_access_point
and ML_egress_point
. If a managed lane is created without explictly setting these values, network wrangler will assume that the managed lanes can be accessed at any node.
The parameter ADDITIONAL_COPY_TO_ACCESS_EGRESS
defines what additional attributes are copied from the general purpose lane to the access and egress links.
name
is created as “
model_link_id
is created as follows, noting that model_link_id
s for managed lanes will be multiples of 10:
- 1 + managed lane’s
model_link_id
for access links - 2 + managed lane’s
model_link_id
for access links
Bases: ConfigItem
Model Roadway Configuration.
Attributes:
Name | Type | Description |
---|---|---|
ML_OFFSET_METERS |
int
|
Offset in meters for managed lanes. |
ADDITIONAL_COPY_FROM_GP_TO_ML |
list[str]
|
Additional fields to copy from general purpose to managed lanes. |
ADDITIONAL_COPY_TO_ACCESS_EGRESS |
list[str]
|
Additional fields to copy to access and egress links. |
Source code in network_wrangler/configs/wrangler.py
Bases: ConfigItem
Model Roadway Configuration.
Attributes:
Name | Type | Description |
---|---|---|
TRANSIT_SHAPE_ID_METHOD |
Literal['scalar']
|
method for creating a shape_id for a transit shape. Should be “scalar”. |
TRANSIT_SHAPE_ID_SCALAR |
int
|
scalar value to add to general purpose lane to create a shape_id for a transit shape. |
ROAD_SHAPE_ID_METHOD |
Literal['scalar']
|
method for creating a shape_id for a roadway shape. Should be “scalar”. |
ROAD_SHAPE_ID_SCALAR |
int
|
scalar value to add to general purpose lane to create a shape_id for a roadway shape. |
ML_LINK_ID_METHOD |
Literal['range', 'scalar']
|
method for creating a model_link_id for an associated link for a parallel managed lane. |
ML_LINK_ID_RANGE |
tuple[int, int]
|
range of model_link_ids to use when creating an associated link for a parallel managed lane. |
ML_LINK_ID_SCALAR |
int
|
scalar value to add to general purpose lane to create a model_link_id when creating an associated link for a parallel managed lane. |
ML_NODE_ID_METHOD |
Literal['range', 'scalar']
|
method for creating a model_node_id for an associated node for a parallel managed lane. |
ML_NODE_ID_RANGE |
tuple[int, int]
|
range of model_node_ids to use when creating an associated node for a parallel managed lane. |
ML_NODE_ID_SCALAR |
int
|
scalar value to add to general purpose lane node ides create a model_node_id when creating an associated nodes for parallel managed lane. |
Source code in network_wrangler/configs/wrangler.py
Network Management ¶
Several functions assist in managing networks themselves including converting serialization formats and clipping to various geographic bounds.
Viewing ¶
Because the roadway network is already in GeoDataFrames, they can be easily viewed in Jupyter Notebooks using commands such as:
my_small_net = SMALL_ROAD.links_df).explore(tiles="CartoDB positron")
SMALL_ROAD.nodes_df.explore(m=my_small_net, color="grey")
my_small_net
For larger networks, you might want to sample objects if you are just trying to get the general picture in order to save memory.
stpaul_net = STPAUL_ROAD.links_df.sample(300).explore(tiles="CartoDB positron")
STPAUL_ROAD.nodes_df.sample(300).explore(m=stpaul_net, color="grey")
stpaul_net
For transit, you have access to GeoDataFrames for both shapes and stops:
STPAUL_TRANSIT.shapes_gdf.explore(m=stpaul_net, color="limegreen")
STPAUL_TRANSIT.stops_gdf.explore(m=stpaul_net, color="limegreen")
stpaul_net
Clipping ¶
There are two options for getting networks that are subsets of the larger one:
- clipping networks already loaded from files. Useful when you are already manipulating the objects.
- filtering the network when it is read in.
In both instances, you have the option to filter based on one of three methods:
boundary_file
which is a geojson or shapefile that you want to filter to.boundary_gdf
passing a geodataframe with a single polygon record that you want to filter to.boundary_geocode
which queries open streetmap for a jurisdiction matching the provided name, e.g. “St Paul, MN, USA”.
Transit additionally has the option to be filtered to a roadway network.
Clipping loaded networks ¶
If your network is already loaded from disk into a RoadwayNetwork or TransitNetwork, you can clip it using clip_roadway()
or clip_transit()
:
from network_wrangler.roadway import clip_roadway
clipped_road_eco = clip_roadway(STPAUL_ROAD, boundary_file=TEST_DATA / "ecolab.geojson")
clipped_road_eco.links_df.explore(m= color="hotpink")
from network_wrangler.transit.clip import clip_transit
clipped_transit_eco = clip_transit(STPAUL_TRANSIT, roadway_net=clipped_road_eco)
Filtering on being read from disk ¶
To filter roadway networks on being read-in, you can use the same parameters (boundary_gdf
, boundary_geocode
or boundary_file
, available in load_roadway_from_dir
, and all associated methods.
This feature is not yet implemented in transit.
Converting Serialization ¶
To convert file serialization without reading it into objects, you can use the method convert_roadway_file_serialization()
:
from roadway.io import convert_roadway_file_serialization
convert_roadway_file_serialization(
my_dir, # the path to the input directory.
"geojson", # the file format of the input files. Defaults to "geojson".
my_new_dir, # the path were the output will be saved.
"parquet", # the format of the output files. Defaults to "parquet".
"new", # the name prefix of the roadway files that will be generated. Defaults to "".
overwrite = True, # if True, will overwrite the files if they already exist. Defaults to True.
)
clip to
Note you can also pass one of boundary_geocode
, boundary_gdf
or boundary_file
to clip while you are converting the file serialization.