From 5eab0d0b741fe1cb6b1bb86fdd2305df97ac4cac Mon Sep 17 00:00:00 2001 From: Dobson Date: Fri, 9 Feb 2024 13:21:42 +0000 Subject: [PATCH] Add river/street graph combine --- swmmanywhere/preprocessing.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/swmmanywhere/preprocessing.py b/swmmanywhere/preprocessing.py index 4d5c5416..f0357a74 100644 --- a/swmmanywhere/preprocessing.py +++ b/swmmanywhere/preprocessing.py @@ -10,6 +10,7 @@ from pathlib import Path import geopandas as gpd +import networkx as nx import pandas as pd from swmmanywhere import geospatial_utilities as go @@ -242,4 +243,21 @@ def run_downloads(bbox: tuple[float, float, float, float], target_crs) gu.save_graph(river_network, addresses.river) else: - print('river network already exists') \ No newline at end of file + print('river network already exists') + +def create_starting_graph(addresses: parameters.FilePaths): + """Create the starting graph. + + Create the starting graph by combining the street and river networks. + + Args: + addresses (FilePaths): Class containing the addresses of the directories. + + Returns: + nx.Graph: Combined street and river network. + """ + river = gu.load_graph(addresses.river) + nx.set_edge_attributes(river, 'river', 'edge_type') + street = gu.load_graph(addresses.street) + nx.set_edge_attributes(street, 'street', 'edge_type') + return nx.compose(river, street) \ No newline at end of file