API Documentatie
damo_afvoergebiedaanvoergebied
Workflow Duikers
Generates culverts to connect the lower level hydroobjects and connect them to the hydroobjects
Workflow GebiedsOrde
Generates order levels and order codes for all hydroobjects including lower level hydroobjects
Workflow Afvoergebieden
Generates drainage units for each hydroobject based on a terrain model
Workflow NetworkLumping
Generates upstream (sub)basins for predefined outflow points
- damo_afvoergebiedaanvoergebied.generator_network_lumping.run_generator_network_lumping(path: Path, dir_basisdata: str = '0_basisdata', dir_results: str = '1_resultaat', direction: str = 'upstream', water_lines: list[str] = None, drainage_units_from_results: str = 'drainage_units_1_gdf.gpkg', include_areas_based_on_id: bool = False, include_areas_based_on_length: bool = False, no_inflow_outflow_points: int = None, detect_split_points: bool = False, smooth_area: bool = False, html_include_units: bool = True, read_results: bool = True, write_results: bool = False, html_file_name: str = None, width_edges: float = 10.0, opacity_edges: float = 0.5, create_html_map: bool = False)[broncode]
- class damo_afvoergebiedaanvoergebied.generator_network_lumping.generator_network_lumping.GeneratorNetworkLumping(*, path: Path = None, name: str = None, base_dir: Path = None, dir_basisdata: str = '0_basisdata', dir_results: str | None = '1_resultaat', read_results: bool = False, write_results: bool = False, required_results: list[str] = ['hydroobjecten', 'hydroobjecten_processed_1'], folium_map: Map = None, direction: str = 'upstream', hydroobjecten: GeoDataFrame = None, hydroobjecten_extra: GeoDataFrame = None, rivieren: GeoDataFrame = None, hydroobjecten_processed_0: GeoDataFrame = None, hydroobjecten_processed_1: GeoDataFrame = None, afwateringseenheden: GeoDataFrame = None, inflow_outflow_points: GeoDataFrame = None, inflow_outflow_splits: GeoDataFrame = None, inflow_outflow_edges: GeoDataFrame = None, inflow_outflow_nodes: GeoDataFrame = None, inflow_outflow_areas: GeoDataFrame = None, inflow_outflow_splits_0: GeoDataFrame = None, inflow_outflow_splits_1: GeoDataFrame = None, inflow_outflow_splits_2: GeoDataFrame = None, edges: GeoDataFrame = None, nodes: GeoDataFrame = None, network_positions: dict = None, graph: DiGraph = None, folium_html_path: str = None)[broncode]
- _abc_impl = <_abc._abc_data object>
- afwateringseenheden: GeoDataFrame
- assign_drainage_units_to_outflow_points_based_on_id()[broncode]
- assign_drainage_units_to_outflow_points_based_on_length_hydroobject()[broncode]
- calculate_angles_of_edges_at_nodes()[broncode]
- create_graph_from_network(water_lines=['hydroobjecten'])[broncode]
Turns a linestring layer containing waterlines into a graph of edges and nodes.
- Parameters
water_lines (list, optional) – List of waterline files names used to create graph, must refer to geopackages containing linestrings, by default [“hydroobjecten”]
- Returns
self.nodes (gpd.GeoDataFrame) – Geodataframe containing nodes between waterlines
self.edges (gpd.GeoDataFrame) – Geodataframe containing edges (waterlines)
self.graph (nx.DiGraph) – Networkx graph containing the edges and nodes
- detect_split_points()[broncode]
Detect all split points where the basins of two or more outflow/inflow points are connecting
- Returns
self.inflow_outflow_splits_1 – gdf with splitpoints, nodeid, downstream_edges_ids, upstream_edges_ids, etc.
- Return type
gpd.GeoDataFrame
- dir_basisdata: str
- dir_results: str | None
- direction: str
- dissolve_assigned_drainage_units(smooth_area=False)[broncode]
- edges: GeoDataFrame
- export_detected_split_points()[broncode]
- export_results_all(html_file_name: str = None, width_edges: float = 10.0, opacity_edges: float = 0.5)[broncode]
Export results to geopackages and folium html
- find_upstream_downstream_nodes_edges(direction: str = 'upstream', no_inflow_outflow_points: int = None)[broncode]
_summary_
- Parameters
direction (str, optional) – _description_, by default “upstream”
no_inflow_outflow_points (int, optional) – _description_, by default None
- Returns
_description_
- Return type
_type_
- Veroorzaakt
ValueError – _description_
- folium_html_path: str
- folium_map: Map
- generate_folium_map(html_file_name: str = None, include_areas: bool = True, width_edges: float = 10.0, opacity_edges: float = 0.5, html_include_units: bool = True, open_html: bool = False, base_map: str = 'OpenStreetMap')[broncode]
Export results to folium html file
- Parameters
html_file_name (str, optional) – filename folium html, by default None
width_edges (float, optional) – width (meters) of edges in folium html, by default 10.0
opacity_edges (float, optional) – opacity of edges in folium html, by default 0.5
- graph: DiGraph
- hydroobjecten: GeoDataFrame
- hydroobjecten_extra: GeoDataFrame
- hydroobjecten_processed_0: GeoDataFrame
- hydroobjecten_processed_1: GeoDataFrame
- inflow_outflow_areas: GeoDataFrame
- inflow_outflow_edges: GeoDataFrame
- inflow_outflow_nodes: GeoDataFrame
- inflow_outflow_points: GeoDataFrame
- inflow_outflow_splits: GeoDataFrame
- inflow_outflow_splits_0: GeoDataFrame
- inflow_outflow_splits_1: GeoDataFrame
- inflow_outflow_splits_2: GeoDataFrame
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str
- network_positions: dict
- nodes: GeoDataFrame
- path: Path
- read_results: bool
- required_results: list[str]
- rivieren: GeoDataFrame
- select_directions_for_splits(fillna_with_random=False)[broncode]
- select_directions_for_splits_based_on_angle()[broncode]
- select_downstream_upstream_edges_angle(min_difference_angle: str = 20.0)[broncode]
- write_results: bool
Workflow Basis
Used for all workflows to load all data from dir_basisdata and dir_results
- class damo_afvoergebiedaanvoergebied.generator_basis.generator_basis.GeneratorBasis(*, path: Path = None, name: str = None, base_dir: Path = None, dir_basisdata: str | pathlib.Path = '0_basisdata', dir_results: str | pathlib.Path | None = '1_resultaat', read_results: bool = False, write_results: bool = False, required_results: list[str] = [], folium_map: Map = None)[broncode]
Basis class for all Generators
Basis class for reading all basis datasets (based on attributes) from the subdirectory basisdata (dir_basisdata) and optionally read results
- Parameters
path (pathlib.Path) – windowspath to analysis folder
name (str) – String representing name of case (equal to folder name)
dir_basisdata (str | pathlib.Path) – String representing subfolder with basisdata
dir_results (str | pathlib.Path) – String representing subfolder with results
read_results (bool) – setting to know whether results in dir_results should be read
write_results (bool) – setting to know whether results should be written in dir_results
required_results (list[str]) – attributes required as input (in the results directory)
folium_map (folium.Map) – folium map
- _abc_impl = <_abc._abc_data object>
- analyse_netwerk_add_information_to_nodes_edges(min_difference_angle=10.0, min_difference_discharge_factor=2.0)[broncode]
- base_dir: Path
- check_case_path_directory(path: Path)[broncode]
Check on existence case directory and structure
- Parameters
path (Path) – path to case directory. name of directory is used as case name. self.path and self.name are set
exist (Raises ValueErrors in case directory and 0_basisdata directory not) –
- create_graph_from_network(water_lines=['hydroobjecten'], processed='processed')[broncode]
Turns a linestring layer containing waterlines into a graph of edges and nodes.
- Parameters
water_lines (list, optional) – List of waterline files names used to create graph, must refer to geopackages containing linestrings, by default [“hydroobjecten”]
- Returns
self.nodes (gpd.GeoDataFrame) – Geodataframe containing nodes between waterlines
self.edges (gpd.GeoDataFrame) – Geodataframe containing edges (waterlines)
self.graph (nx.DiGraph) – Networkx graph containing the edges and nodes
- dir_basisdata: str | pathlib.Path
- dir_results: str | pathlib.Path | None
- export_results_to_gpkg_or_nc(list_layers: list[str] = None, dir_output: str | pathlib.Path = None)[broncode]
Export results to geopackages in folder 1_resultaat
- folium_map: Map
- generate_or_use_preprocessed_hydroobjecten(waterline, preprocessed_file='preprocessed', snapping_distance=0.05)[broncode]
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str
- path: Path
- read_data_from_case(path: Path = None, read_results: bool = None)[broncode]
Read data from case: including basis data and intermediate results
- Parameters
path (Path, optional) – Path to the case directory including directories 0_basisdata and 1_resultaat. Directory name is used as name for the case, by default None
read_results (bool, optional) – if True, it reads already all resulst from, by default None
- read_required_data_from_case()[broncode]
Check if required results (from previous analyses) is available
This function check if all required datasets are imported.
- Veroorzaakt
ValueError – if required dataset is not available
- read_results: bool
- required_results: list[str]
- select_downstream_upstream_edges(min_difference_angle=10.0, min_difference_discharge_factor=2.0)[broncode]
- use_processed_hydroobjecten(processed_file='processed', force_preprocess=False, snapping_distance=0.05)[broncode]
actualize hydroobjecten and overige_watergangen
replaces hydroobjecten and overige_watergangen with the newest processed attributes
- Parameters
processed_file (str, optional) – suffix of processed files, by default “processed”
- write_results: bool
Utils
- damo_afvoergebiedaanvoergebied.utils.create_graph.add_basin_code_from_network_to_nodes_and_edges(graph: DiGraph, nodes: GeoDataFrame, edges: GeoDataFrame)[broncode]
add basin (subgraph) code to nodes and edges
- damo_afvoergebiedaanvoergebied.utils.create_graph.create_graph_based_on_nodes_edges(nodes: GeoDataFrame, edges: GeoDataFrame, directional_graph: bool = True, add_edge_length_as_weight: bool = False, print_logmessage: bool = True) networkx.classes.graph.Graph | networkx.classes.digraph.DiGraph[broncode]
create networkx graph based on geographic nodes and edges. default a directional graph.
- damo_afvoergebiedaanvoergebied.utils.create_graph.create_graph_from_edges(edges: GeoDataFrame, directed=True, integer_labels=True)[broncode]
- damo_afvoergebiedaanvoergebied.utils.create_graph.generate_nodes_from_edges(edges: GeoDataFrame) tuple[geopandas.geodataframe.GeoDataFrame, geopandas.geodataframe.GeoDataFrame][broncode]
Generate start/end nodes from edges and update node information in edges GeoDataFrame. Return updated edges geodataframe and nodes geodataframe
- Parameters
edges (gpd.GeoDataFrame) – Line feature dataset containing edges
- Return type
Tuple containing GeoDataFrame with edges and GeoDataFrame with nodes
- damo_afvoergebiedaanvoergebied.utils.folium_utils.add_basemaps_to_folium_map(m: Map, base_map='Light Mode')[broncode]
- damo_afvoergebiedaanvoergebied.utils.folium_utils.add_categorized_color_to_gdf(gdf, color_column=None, colormap='RdBu', names=None, thresholds=None, lower_limit=True, upper_limit=True, colors=None, new_name_column=None, new_color_column=None, label_unit='', label_decimals=2)[broncode]
- damo_afvoergebiedaanvoergebied.utils.folium_utils.add_categorized_lines_to_map(m: ~folium.folium.Map, lines_gdf: ~geopandas.geodataframe.GeoDataFrame, feature_group: ~folium.map.FeatureGroup = None, control: bool = True, layer_name: str = 'categorized lines', lines: bool = True, line_color_column: str = 'black', line_color_category_names: list[str] = None, line_color_category_thresholds: list[float] = None, line_color_category_lower_limit: bool = True, line_color_category_upper_limit: bool = True, line_color_category_colors: list[str] = None, line_color_cmap: str = None, line_weight: int = 2, label: bool = False, label_column: str = None, label_unit: str = '', label_decimals: int = 2, label_fontsize: int = 10, z_index: int = 1, dash_array: str = None, legend: bool = False, legend_name: str = None, legend_location: str = 'top', show: bool = True, tooltip: [list[str], <class 'str'>, <class 'bool'>] = False, tooltip_aliases: [list[str], <class 'str'>] = None, popup: [list[str], <class 'str'>, <class 'bool'>] = False, popup_aliases: [list[str], <class 'str'>] = None)[broncode]
Voegt lijnen toe aan de kaart met kleuren zoals gedefinieerd in de categorieen. Input zoals in add_lines_to_map met als toevoeging: * color_column: de kolomnaam waar de kleur van de lijn op gebaseerd wordt * color_category_names: lijst met de categorieën in woorden. * color_category_thresholds: lijst met de waarden van de grenzen voor de categorieen * color_category_lower_limit: True voor een extra categorie voor alle waarden lager dan je laagste categorie * color_category_upper_limit: True voor een extra categorie voor alle waarden hoger dan je hoogste categorie * color_category_colors: lijst met kleuren behorend bij de categorieen * legend: bool = False voor weergeven van legenda, False voor geen legenda * legend_name: Naam die boven de legenda wordt weergegeven, * legend_location: locatie van de legenda, bottom of top
- damo_afvoergebiedaanvoergebied.utils.folium_utils.add_categorized_raster_to_map(self, raster: DataArray, dx: float = 0.0, dy: float = 0.0, feature_group: FeatureGroup = None, layer_name: str = '', unit: str = 'm', control: bool = True, category_values: list[float | int] = None, category_names: list[float | int | str] = None, category_thresholds: list[float | int] = None, category_lower_limit: bool = True, category_upper_limit: bool = True, category_cmap: str = None, category_colors: list[str] = None, opacity: float = 1.0, legend: bool = False, legend_name: str = None, legend_location: str = 'top', legend_reverse: bool = False, z_index: int = 1, show=True) FeatureGroup[broncode]
- Voegt raster toe aan swecoleaflet op basis van zelf gedefinieerde categorieen
Input: zie add_raster_to_map, met als toevoeging
category_values: lijst met rasterwaardes per category
category_names: lijst met category namen
category_thresholds: lijst met de waarden van de grenzen voor de categorieen
category_lower_limit: True voor een extra categorie voor alle waarden lager dan je laagste categorie
category_upper_limit: True voor een extra categorie voor alle waarden hoger dan je hoogste categorie
category_cmap: matploblib-colormap
category_colors: lijst met kleuren behorend bij de categorieen
output: feature group
- damo_afvoergebiedaanvoergebied.utils.folium_utils.add_graduated_raster_to_map(m: Map, raster: DataArray, dx: float = 0.0, dy: float = 0.0, feature_group: FeatureGroup = None, layer_name: str = None, unit: str = '', control: bool = True, cmap: str = 'Spectral', values: list[float | int] = None, colors: list[str] = None, vmin: float = None, vmax: float = None, upper_limit: bool = False, lower_limit: bool = False, opacity: float = 0.5, z_index: int = 1, legend: bool = False, legend_name: str = None, legend_location: str = 'top', legend_reverse: bool = False, show=True) FeatureGroup[broncode]
- Voegt raster toe aan swecoleaflet
- Input: * raster: raster
layer_name: De naam van de laag zoals deze verschijnt in de lijst met lagen in de kaart
feature_group: Vul hier de featuregroup naam in indien je meerdere lagen in één groep plaatst
unit: de eenheid van de waarde in je raster, om eventueel weer te geven in legenda
cmap: de naam van de te gebruiken colormap volgens de built-in colormaps van matplotlib
vmin: de minimale waarde voor je colormap
vmax: de maximale waarde voor je colormap
opacity: vul een waarde tussen 0.0 (volledig transparant) en 1.0 in (volledig ontransparant)
show: Geef met True of False aan of de laag standaard weergegeven moet worden bij openen van de kaart.
control: Geef met True of False aan of de laag opgenomen moet worden in de lijst met lagen
z_index: bij meerdere lagen; geef met een waarde aan welke laag op de voorgrond weergegeven wordt
legend: bool = False voor weergeven van legenda, False voor geen legenda
legend_name: Naam die boven de legenda wordt weergegeven,
legend_location: locatie van de legenda, bottom of top
legend_reverse: True als je de legenda andersom wil weergeven (laagste waarde boven, hoogste onder)
Output = swecoleaflet
- damo_afvoergebiedaanvoergebied.utils.folium_utils.add_labels_to_points_lines_polygons(gdf: GeoDataFrame, column: str, label_fontsize: int = 14, label_unit: str = '', label_decimals: int = 2, show: bool = True, center=True, fg=None, fgs=None)[broncode]
- damo_afvoergebiedaanvoergebied.utils.folium_utils.add_lines_to_map(m: ~folium.folium.Map, lines_gdf: ~geopandas.geodataframe.GeoDataFrame, layer_name: str, lines: bool = True, feature_group: ~folium.map.FeatureGroup = None, control: bool = True, show: bool = True, line_color: str = 'black', line_color_name: str = 'XXXXXXXXXXXXXXXX', line_weight: int = 2, line_opacity: float = 0, label: bool = False, label_column: str = None, label_unit: str = '', label_decimals: int = 2, label_fontsize: int = 10, z_index: int = 1, dash_array: str = None, tooltip: [list[str], <class 'str'>, <class 'bool'>] = False, tooltip_aliases: [list[str], <class 'str'>] = None, popup: [list[str], <class 'str'>, <class 'bool'>] = False, popup_aliases: [list[str], <class 'str'>] = None)[broncode]
Voegt lijnen toe aan de kaart
- Input:
lines_gdf: Geodataframe with lines
layer_name: De naam van de laag zoals deze verschijnt in de lijst met lagen in de kaart
feature_group: Vul hier de featuregroup naam in indien je meerdere lagen in één groep plaatst
color: Vul hier de kleur van de lijn in. Kies een standaard kleur volgens matplotlib of gebruik een HEX kleurcode
weight: de dikte van de lijn
line_opacity: Vul een waarde tussen 0.0 (volledig transparant) en 1.0 in (volledig ontransparant)
dash_array: geef hier de string met je definitie voor een stippellijn. bijvoorbeeld “10 5” geeft een stippellijn met lijnstukjes lengte 10 en lege stukken met lengte 5
label: Kies True als je een label wil weergegeven. label_column vereist
label_column: Vul de naam van de kolom in waar de tekst voor je label in staat.
label_decimals: Indien je label een getal is, geef hier aan met hoeveel decimalen deze weergegeven moet worden
label_fontsize: Kies de fontsize van de label tekst
show: Geef met True of False aan of de laag standaard weergegeven moet worden bij openen van de kaart.
control: Geef met True of False aan of de laag opgenomen moet worden in de lijst met lagen
tooltip: Geef in een list aan welke kolommen weergegeven moeten worden als je met je muis over de feature in de kaart beweegt. Bij True worden alle kolommen weergegeven, bij False geen.
tooltip_aliases: Geef een list met alisases op voor de kolomnamen zoals deze verschijnen in de kaart. Het eerste item uit je list is de alias voor het eerste item in de list zoals opgegeven bij tooltip.
popup: Geeft de informatie bij klikken op de fetaure in de kaart. Werking; zie tooltip.
popup_alisases: Geeft aliases voor de popup. Werking; zie tooltip_aliases
z_index: bij meerdere lagen; geef met een waarde aan welke laag op de voorgrond weergegeven wordt
- Output
feature_group
- damo_afvoergebiedaanvoergebied.utils.folium_utils.check_fields_aliases(df: [<class 'pandas.core.frame.DataFrame'>, <class 'pandas.core.series.Series'>, <class 'geopandas.geodataframe.GeoDataFrame'>, <class 'geopandas.geoseries.GeoSeries'>], fields: [list[str], <class 'str'>, <class 'bool'>] = False, aliases: [list[str], <class 'str'>] = None)[broncode]
Does a check on the tooltips (fields and aliases) and the popups (fields and aliases)
- damo_afvoergebiedaanvoergebied.utils.folium_utils.check_map_exists_and_feature_group(m: Map = None, feature_group: FeatureGroup = None, layer_name: str = None, show: bool = True, control: bool = True, z_index: int = 1)[broncode]
- Two things:
checks if map (self.m) exists and if not creates it.
creates a feature group (layer) and if input includes feature group, it creates a subgroup
- Input: * feature_group: an existing feature_group (a subgroup will be created)
or None (a feature_group will be created)
layer_name: string representing name of the layer
show: True/False - is the layer selected or not
control: True/False - is the layer included in the layercontrol legend
z_index: z of the layer (does not always work well…)
- damo_afvoergebiedaanvoergebied.utils.folium_utils.create_categories_based_on_thresholds(thresholds: list[float], unit: str = 'm', lower_limit: bool = True, upper_limit: bool = True, decimals: int = 2)[broncode]
This function creates categories based on a list of tresholds.
- Input: * thresholds: A list of floats
unit: str indicating the unit. in case unit == % then 0.3 –> 30%
lower_limit: Also a category “everything below lowest threshold”
upper_limit: Also a category “everything above highest threshold”
decimals: number of decimals included in category-name
- Output: * thresholds: list of thresholds (adapted in case of upper- and/or lower_limit)
categories: names of the categories
- damo_afvoergebiedaanvoergebied.utils.folium_utils.create_legend_format(line_colors: list[str] = None, fill_colors: list[str] = None, line_weight: float = 1.0, labels: list[str] = None, legend_title: str = 'Legenda', opacity: float = 0.0, no_legend: int = 0, legend_location: str = 'top', reverse: bool = False)[broncode]
Generate a color legend based on colors and labels
- Input: * line_colors: list of colors specified by strings (hex)
fill_colors: list of colors specified by strings (hex)
labels: list of labels attached to colors (categories?)
legend_title: title of the legend
opacity: opacity of the legend 0.0-1.0
no_legend: number of legend (location at top or bottom)
legend_location: location of legend (‘top’ or ‘bottom’)
reverse: reverse the order of the colors/labels (high->low versus low->high)
Output: * macro including the legend, which can be added to the map.
- damo_afvoergebiedaanvoergebied.utils.general_functions._remove_holes(geom, min_area)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.calculate_angle(line, direction)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.calculate_angle_difference(angle1, angle2)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.calculate_angle_end(line)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.calculate_angle_reverse(line)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.calculate_angle_start(line)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.check_and_flip(line, start_points, end_points)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.check_duplicate_codes(gdf, column)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.find_edge_smallest_angle_difference(reference_angle, angles, edge_codes)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.get_endpoints_from_lines(lines: GeoDataFrame) GeoDataFrame[broncode]
Extract all unique endpoints of line features from vector data
- Parameters
lines (gpd.GeoDataFrame) – GeoDataFrame containing line features
- Returns
GeoDataFrame containing all unique endpoints from line features
- Return type
gpd.GeoDataFrame
- damo_afvoergebiedaanvoergebied.utils.general_functions.line_to_vertices(gdf, distance=10.0, keep_columns=['code', 'WaterLineType'])[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.remove_holes_from_basin_areas(basin_areas: GeoDataFrame, min_area: float)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.remove_holes_from_polygons(geom: _Geom, min_area: float) _Geom[broncode]
Remove all holes from a geometry that satisfy the filter function.
- damo_afvoergebiedaanvoergebied.utils.general_functions.remove_z_dims(_gdf: GeoDataFrame)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.shorten_line_two_vertices(line, offset)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.snap_unconnected_endpoints_to_endpoint_or_line(hydroobjecten, snapping_distance=0.05)[broncode]
- damo_afvoergebiedaanvoergebied.utils.general_functions.split_waterways_by_endpoints(hydroobjects, relevant_culverts)[broncode]
- damo_afvoergebiedaanvoergebied.utils.network_functions.accumulate_values_graph(from_node_ids, to_node_ids, node_ids, edge_ids, values_node_ids, values_nodes, values_edge_ids, values_edges, border_node_ids=None, itself=False, direction='upstream', decimals=None)[broncode]
Calculate for all node_ids the accumulated values of all predecessors with values.
- damo_afvoergebiedaanvoergebied.utils.network_functions.calculate_angles_of_edges_at_nodes(nodes: GeoDataFrame, edges: GeoDataFrame, nodes_id_column: str = 'nodeID')[broncode]
Calculates the angles of the upstream and downstream edges for each node.
- Returns
self.nodes – Geodataframe containing nodes between waterlines, including upstream and downstream edges and their angles
- Return type
gpd.GeoDataFrame
- damo_afvoergebiedaanvoergebied.utils.network_functions.calculate_discharges_of_edges_at_nodes(nodes: GeoDataFrame, edges: GeoDataFrame, nodes_id_column: str = 'nodeID')[broncode]
Calculates the angles of the upstream and downstream edges for each node.
- Returns
self.nodes – Geodataframe containing nodes between waterlines, including upstream and downstream edges and their angles
- Return type
gpd.GeoDataFrame
- damo_afvoergebiedaanvoergebied.utils.network_functions.define_list_upstream_downstream_edges_ids(node_ids: array, nodes: GeoDataFrame, edges: GeoDataFrame, nodes_id_column: str = 'nodeID', edges_id_column: str = 'code')[broncode]
Get the upstream and downstream edges for each node.
- Returns
self.nodes – Geodataframe containing nodes between waterlines, including upstream and downstream edges
- Return type
gpd.GeoDataFrame
- damo_afvoergebiedaanvoergebied.utils.network_functions.find_node_edge_ids_in_directed_graph(from_node_ids, to_node_ids, edge_ids, outflow_edge_ids, search_node_ids, search_edge_ids, border_node_ids=None, direction='upstream', split_points=None, set_logging=False, order_first=False, new_order_at_splits=False)[broncode]
- damo_afvoergebiedaanvoergebied.utils.network_functions.find_nodes_edges_for_direction(nodes: GeoDataFrame, edges: GeoDataFrame, outflow_edge_ids: list, border_node_ids: list = None, direction: str = 'upstream', split_points: GeoDataFrame = None, order_first: bool = False)[broncode]
- damo_afvoergebiedaanvoergebied.utils.network_functions.find_predecessors_graph(from_node_ids: array, to_node_ids: array, edge_ids: array, edge_id: int, border_node_ids: array = None, pred_nodes: list = [], pred_edges: list = [])[broncode]
Find predecessors within graph for specified node_id.
Note: recursive function!
- damo_afvoergebiedaanvoergebied.utils.network_functions.find_predecessors_graph_with_splits(from_node_ids, to_node_ids, edge_ids, edge_id, border_node_ids=None, split_node_edge_ids=None, split_node_edge_ids2=None, pred_nodes=[], pred_edges=[], new_outflow_edges=[])[broncode]
Find predecessors within graph for specified node_id.
Note: recursive function!
- damo_afvoergebiedaanvoergebied.utils.network_functions.get_start_edges_nodes(edges, nodes, direction='downstream')[broncode]
Function to get the starting edges of the graph. This function identifies nodes that do not have
- damo_afvoergebiedaanvoergebied.utils.network_functions.select_downstream_upstream_edges_angle(nodes, min_difference_angle: float = 20.0)[broncode]
select the upstream or downstream edge that represents the main channel, based on the smallest angle. When the angle of both edges is too large, no edge is selected.
- Parameters
min_difference_angle (str, optional) – minimum , by default 20.0
- Returns
gpd.GeoDataFrame – Geodataframe containing nodes between waterlines, including the selected upstream and downstream angles
- Return type
self.nodes
- damo_afvoergebiedaanvoergebied.utils.network_functions.select_downstream_upstream_edges_discharge(nodes, min_difference_discharge_factor: float = 2.0)[broncode]
select the upstream or downstream edge that represents the main channel, based on the smallest angle. When the angle of both edges is too large, no edge is selected.
- Parameters
min_difference_angle (str, optional) – minimum , by default 20.0
- Returns
gpd.GeoDataFrame – Geodataframe containing nodes between waterlines, including the selected upstream and downstream angles
- Return type
self.nodes
- damo_afvoergebiedaanvoergebied.utils.network_functions.sum_edge_node_values_through_network(edges, nodes, edges_nodes='edges', edges_id_column='code', nodes_id_column='nodeID', direction='downstream', column_to_sum='specific_discharge', sum_column='total_specific_discharge')[broncode]
- exception damo_afvoergebiedaanvoergebied.utils.pandas_xlsx_tables.TableNotFound[broncode]
- damo_afvoergebiedaanvoergebied.utils.pandas_xlsx_tables.create_format_mapping(workbook)[broncode]
- damo_afvoergebiedaanvoergebied.utils.pandas_xlsx_tables.df_to_xlsx_table(df: DataFrame, table_name: str, file: Optional[Union[str, BinaryIO]] = None, index: bool = True, table_style: Optional[TableStyleInfo] = 'Table Style Medium 9', nan_inf_to_errors=False, header_orientation: Literal['diagonal', 'horizontal', 'vertical'] = 'horizontal', remove_timezone: bool = False) None[broncode]
Convert single dataframe to an excel file.
- Parameters
df (DataFrame) – Padas dataframe to convert to excel.
table_name (str) – Name of the table.
file (Union[str, BinaryIO]) – File name or descriptor for the output. Defaults to <table_name>.xlsx
index (bool, optional) – Include the datafrme index in the results. Defaults to True
table_style (Optional[NamedTableStyle], optional) – Excel table style. Defaults to “Table Style Medium 9”.
nan_inf_to_errors (bool, optional) – Explicitly write nan/inf values as errors. Defaults to False.
header_orientation (HeaderOrientation, optional) – Rotate the table headers, can be horizontal, vertical or diagonal. Defaults to “horizontal”.
- damo_afvoergebiedaanvoergebied.utils.pandas_xlsx_tables.dfs_to_xlsx_tables(input: Iterable[tuple[pandas.core.frame.DataFrame, str]], file: Union[str, BinaryIO], index: bool = True, table_style: Optional[Literal['Table Style Dark 1', 'Table Style Dark 2', 'Table Style Dark 3', 'Table Style Dark 4', 'Table Style Dark 5', 'Table Style Dark 6', 'Table Style Dark 7', 'Table Style Dark 8', 'Table Style Dark 9', 'Table Style Dark 10', 'Table Style Dark 11', 'Table Style Light 1', 'Table Style Light 2', 'Table Style Light 3', 'Table Style Light 4', 'Table Style Light 5', 'Table Style Light 6', 'Table Style Light 7', 'Table Style Light 8', 'Table Style Light 9', 'Table Style Light 10', 'Table Style Light 11', 'Table Style Light 12', 'Table Style Light 13', 'Table Style Light 14', 'Table Style Light 15', 'Table Style Light 16', 'Table Style Light 17', 'Table Style Light 18', 'Table Style Light 19', 'Table Style Light 20', 'Table Style Light 21', 'Table Style Medium 1', 'Table Style Medium 2', 'Table Style Medium 3', 'Table Style Medium 4', 'Table Style Medium 5', 'Table Style Medium 6', 'Table Style Medium 7', 'Table Style Medium 8', 'Table Style Medium 9', 'Table Style Medium 10', 'Table Style Medium 11', 'Table Style Medium 12', 'Table Style Medium 13', 'Table Style Medium 14', 'Table Style Medium 15', 'Table Style Medium 16', 'Table Style Medium 17', 'Table Style Medium 18', 'Table Style Medium 19', 'Table Style Medium 20', 'Table Style Medium 21', 'Table Style Medium 22', 'Table Style Medium 23', 'Table Style Medium 24', 'Table Style Medium 25', 'Table Style Medium 26', 'Table Style Medium 27', 'Table Style Medium 28']] = 'Table Style Medium 9', nan_inf_to_errors=False, header_orientation: Literal['diagonal', 'horizontal', 'vertical'] = 'horizontal', remove_timezone: bool = False) None[broncode]
Convert multiple dataframes to an excel file.
- Parameters
input (Iterable[tuple[DataFrame, str]]) – A list of tuples of (df, table_name)
file (Union[str, BinaryIO]) – File name or descriptor for the output
index (bool, optional) – Include the datafrme index in the results. Defaults to True
table_style (Optional[NamedTableStyle], optional) – Excel table style. Defaults to “Table Style Medium 9”.
nan_inf_to_errors (bool, optional) – Explicitly write nan/inf values as errors. Defaults to False.
header_orientation (HeaderOrientation, optional) – Rotate the table headers, can be horizontal, vertical or diagonal. Defaults to “horizontal”.
- damo_afvoergebiedaanvoergebied.utils.pandas_xlsx_tables.format_for_col(col: Series, format_mapping: dict)[broncode]
- damo_afvoergebiedaanvoergebied.utils.pandas_xlsx_tables.table_to_df(ws: ReadOnlyWorksheet, table: Table, index, values_as_nan={'#N/A', '#NAME?', '#NULL!', '#NUM!', '#REF!', '#VALUE!'}, values_as_inf={'#DIV/0!'}, values_as_empty_string={None}) DataFrame[broncode]
- damo_afvoergebiedaanvoergebied.utils.pandas_xlsx_tables.xlsx_table_to_df(file, table: str, index: Union[Literal['auto'], int, Iterable[int]] = 'auto')[broncode]
Get a table from a given workbook by the tablename.
- damo_afvoergebiedaanvoergebied.utils.pandas_xlsx_tables.xlsx_tables_to_dfs(file, index: [typing.Literal['auto'], <class 'int'>, typing.Iterable[int]] = 'auto')[broncode]
Get all tables from a given workbook. Returns a dictionary of tables. Requires a filename, which includes the file path and filename.
Inspired by: https://github.com/pandas-dev/pandas/issues/24862#issuecomment-458885960 https://stackoverflow.com/questions/43941365/openpyxl-read-tables-from-existing-data-book-example
- damo_afvoergebiedaanvoergebied.utils.preprocess.preprocess_hydroobjecten(hydroobjecten, snapping_distance=0.05)[broncode]