MTCRoadwayNetwork¶
models.mtc_network.MTCRoadwayNetwork
¶
Bases: RoadwayNetwork
MTC-specific roadway network with additional validation.
Extends RoadwayNetwork to enforce MTC-specific schema requirements including county, jurisdiction, and mtc_facility_type fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes_df
|
GeoDataFrame of roadway nodes |
None
|
|
links_df
|
GeoDataFrame of roadway links |
None
|
|
shapes_df
|
GeoDataFrame of roadway shapes (optional) |
None
|
|
validate_mtc
|
bool
|
If True, validates against MTC schemas (default: True) |
True
|
**kwargs
|
Additional arguments passed to RoadwayNetwork |
{}
|
Example
from mtc_wrangler.models.mtc_network import MTCRoadwayNetwork
# Load a network with MTC validation
net = MTCRoadwayNetwork.read(
link_file="links.geojson",
node_file="nodes.geojson",
validate_mtc=True
)
# Access network data
print(net.links_df[['model_link_id', 'county', 'jurisdiction']])
Source code in models/mtc_network.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 | |
__init__(nodes_df=None, links_df=None, shapes_df=None, validate_mtc: bool = True, **kwargs)
¶
Initialize MTC Roadway Network with optional MTC-specific validation.
Source code in models/mtc_network.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
validate()
¶
Validate network against MTC-specific schemas.
This method can be called explicitly to validate the network after modifications have been made to the dataframes.
Example
# Modify network
net.links_df['county'] = 'Alameda'
# Validate changes
net.validate()
Source code in models/mtc_network.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
read(link_file: Union[str, Path], node_file: Union[str, Path], shape_file: Optional[Union[str, Path]] = None, validate_mtc: bool = True, **kwargs) -> MTCRoadwayNetwork
classmethod
¶
Read network from files with MTC validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_file
|
Union[str, Path]
|
Path to links file (GeoJSON, shapefile, etc.) |
required |
node_file
|
Union[str, Path]
|
Path to nodes file (GeoJSON, shapefile, etc.) |
required |
shape_file
|
Optional[Union[str, Path]]
|
Optional path to shapes file |
None
|
validate_mtc
|
bool
|
If True, validates against MTC schemas (default: True) |
True
|
**kwargs
|
Additional arguments passed to parent read method |
{}
|
Returns:
| Type | Description |
|---|---|
MTCRoadwayNetwork
|
MTCRoadwayNetwork instance |
Example
net = MTCRoadwayNetwork.read(
link_file="data/links.geojson",
node_file="data/nodes.geojson",
validate_mtc=True
)
Source code in models/mtc_network.py
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 | |
write(out_dir: Union[str, Path], validate_mtc: bool = True, **kwargs)
¶
Write network to files with optional MTC validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_dir
|
Union[str, Path]
|
Output directory for network files |
required |
validate_mtc
|
bool
|
If True, validates against MTC schemas before writing |
True
|
**kwargs
|
Additional arguments passed to parent write method |
{}
|
Example
net.write("output/network", validate_mtc=True)
Source code in models/mtc_network.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |