Reference for SWMManywhere/preprocessing.py
Preprocessing module for SWMManywhere.
A module to call downloads, preprocess these downloads into formats suitable for graphfcns, and some other utilities (such as creating a project folder structure or create the starting graph from rivers/streets).
create_starting_graph(addresses)
Create the starting graph.
Create the starting graph by combining the street and river networks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
addresses
|
FilePaths
|
Class containing the addresses of the directories. |
required |
Returns:
Type | Description |
---|---|
nx.Graph: Combined street and river network. |
Source code in swmmanywhere/preprocessing.py
prepare_building(bbox, addresses, target_crs)
Download and reproject building data.
Source code in swmmanywhere/preprocessing.py
prepare_elevation(bbox, addresses, target_crs)
Download and reproject elevation data.
Source code in swmmanywhere/preprocessing.py
prepare_precipitation(bbox, addresses, api_keys, target_crs, source_crs='EPSG:4326')
Download and reproject precipitation data.
Source code in swmmanywhere/preprocessing.py
prepare_river(bbox, addresses, target_crs, source_crs='EPSG:4326')
Download and reproject river graph.
Source code in swmmanywhere/preprocessing.py
prepare_street(bbox, addresses, target_crs, source_crs='EPSG:4326', network_types=['drive'])
Download and reproject street graph.
Download the street graph within the bbox and reproject it to the UTM zone. The street graph is downloaded for all network types in network_types. The street graph is saved to the addresses.bbox_paths.street directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bbox
|
tuple[float, float, float, float]
|
Bounding box coordinates in the format (minx, miny, maxx, maxy) in EPSG:4326. |
required |
addresses
|
FilePaths
|
Class containing the addresses of the directories. |
required |
target_crs
|
str
|
Target CRS to reproject the graph to. |
required |
source_crs
|
str
|
Source CRS of the graph. |
'EPSG:4326'
|
network_types
|
list
|
List of network types to download. For duplicate
edges, nx.compose_all selects the attributes in priority of last to
first. In likelihood, you want to ensure that the last network in
the list is |
['drive']
|
Source code in swmmanywhere/preprocessing.py
run_downloads(bbox, addresses, network_types=['drive'])
Run the data downloads.
Run the precipitation, elevation, building, street and river network downloads. If the data already exists, do not download it again. Reprojects data to the UTM zone.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bbox
|
tuple[float, float, float, float]
|
Bounding box coordinates in the format (minx, miny, maxx, maxy) in EPSG:4326. |
required |
addresses
|
FilePaths
|
Class containing the addresses of the directories. |
required |
network_types
|
list
|
List of network types to download. |
['drive']
|
Source code in swmmanywhere/preprocessing.py
write_df(df, fid)
Write a DataFrame to a file.
Write a DataFrame to a file. The file type is determined by the file extension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame to write to a file. |
required |
fid
|
Path
|
Path to the file. |
required |