Skip to main content

layout

layout

Layout of a model on the map: nodes not on top of each other, and links without overlapping segments.

This only changes node and link geometries, which Ribasim does not use in the simulation.

Classes

Name Description
Water The water surfaces of the BGT, read per tile when they are needed, see ribasim_nl.bgt_water.read_bgt_water.

Water

layout.Water(path=BGT_WATER, tile=5000.0, margin=MAX_WATER_DISTANCE)

The water surfaces of the BGT, read per tile when they are needed, see ribasim_nl.bgt_water.read_bgt_water.

Parameters

Name Type Description Default
path Path GeoParquet file of the BGT water BGT_WATER
tile float size of the tiles that are read [m] 5000.0
margin float water that is read around a tile, within which points of the tile are looked up [m] MAX_WATER_DISTANCE

Methods

Name Description
contains Whether a point lies on the water, or on its edge.
onto The nearest point of the water to a point on land, and inside further in that direction if still water.
contains
layout.Water.contains(point)

Whether a point lies on the water, or on its edge.

onto
layout.Water.onto(point, max_distance, inside=0.5, within=None)

The nearest point of the water to a point on land, and inside further in that direction if still water.

Parameters
Name Type Description Default
within shapely.Geometry | None only the water within this area counts, defaults to None (all water) None
Returns
Name Type Description
shapely.Point | None None if the point lies on the water, or more than max_distance from it

Functions

Name Description
coincident_nodes Pairs of node ids that are within distance of each other, as an array of shape (2, n).
junction_areas Per Junction of a Basin tree, see ribasim_nl.flow_paths.Routes, the area of its Basin.
junctions_onto_water Move the Junctions that lie on land, within max_distance of the water, onto the water, see Water.onto.
move_nodes Move nodes, and the ends of their links along.
offset_links Offset links to the right of their direction, like traffic, keeping their ends at their nodes.
overlapping_links Pairs of flow and observation link ids that overlap over more than min_length, as an array of shape (2, n).
place_bergend_nodes Place each bergend Basin distance from its doorgaand Basin, and its connector halfway.
resolve_overlaps Offset links that still overlap other links further to their right, see offset_links.
separate_nodes Move nodes that are within min_distance of another node, such that no nodes are on top of each other.
tidy_layout Make the layout of a model readable: no nodes on top of each other, and no overlapping links.

coincident_nodes

layout.coincident_nodes(model, distance)

Pairs of node ids that are within distance of each other, as an array of shape (2, n).

junction_areas

layout.junction_areas(model)

Per Junction of a Basin tree, see ribasim_nl.flow_paths.Routes, the area of its Basin.

A Junction is part of the routes of its Basin, so where it is moved to tidy the layout, it stays in this area: not on the water of a neighbor on the other side of a dike, or behind the structure that its routes lead to.

junctions_onto_water

layout.junctions_onto_water(
    model,
    water,
    max_distance=MAX_WATER_DISTANCE,
    node_ids=None,
    trim=True,
    areas=None,
)

Move the Junctions that lie on land, within max_distance of the water, onto the water, see Water.onto.

A Junction is where routes join or split, which belongs on the water, but routes can share a stretch over land, such as through a culvert or from a structure on a dike. Only the water in the area of its Basin counts, see junction_areas: a Junction next to a gemaal on a dike does not move onto the river behind it. The ends of its links move along, and with trim the links go straight to the Junction from the distance of the move, see move_nodes.

Parameters

Name Type Description Default
node_ids typing.Collection[int] | None the Junctions to move, defaults to all Junctions None
areas typing.Mapping[int, shapely.Geometry] | None per Junction, the area of its Basin, defaults to None (junction_areas) None

move_nodes

layout.move_nodes(model, locations, trim=False)

Move nodes, and the ends of their links along.

Parameters

Name Type Description Default
trim bool let the links go straight to the moved nodes from the distance of the move, see _set_link_ends, for small moves that tidy the layout False

place_bergend_nodes

layout.place_bergend_nodes(model, distance=100.0, directions=16)

Place each bergend Basin distance from its doorgaand Basin, and its connector halfway.

The direction is the one with the most room to other links and nodes, within the area of the doorgaand Basin. If no direction fits at distance, half that distance is tried, and so on, and finally also directions outside the area.

Parameters

Name Type Description Default
model Model Ribasim model, with meta_categorie “bergend” for the bergend Basins required
distance float distance between the bergend and the doorgaand Basin 100.0
directions int number of directions to try 16

resolve_overlaps

layout.resolve_overlaps(model, distance=5.0, min_length=1.0, max_iterations=5)

Offset links that still overlap other links further to their right, see offset_links.

These are for instance the links of neighboring Basins along a shared waterway.

separate_nodes

layout.separate_nodes(
    model,
    min_distance=NODE_SPACING,
    water=None,
    trim=True,
    areas=None,
)

Move nodes that are within min_distance of another node, such that no nodes are on top of each other.

Of two such nodes, the most movable one is moved, see MOVABLE_NODE_TYPES; Basins are never moved. It is moved to the first free location around the other node, starting in the direction away from it. A Junction goes to the first free location in the area of its Basin, see junction_areas, and of these to the first one on the water, if given and there is one. With trim, the links of a moved node go straight to it from the distance of the move, see move_nodes.

Parameters

Name Type Description Default
areas typing.Mapping[int, shapely.Geometry] | None per Junction, the area of its Basin, defaults to None (junction_areas) None

tidy_layout

layout.tidy_layout(
    model,
    *,
    offset=5.0,
    min_distance=NODE_SPACING,
    bergend_distance=100.0,
    water_path=None,
)

Make the layout of a model readable: no nodes on top of each other, and no overlapping links.

The inflows and outflows of a Basin share one Junction tree, see ribasim_nl.flow_paths.Routes, so links stay on their route, and only links that still overlap are offset. See place_bergend_nodes, separate_nodes and resolve_overlaps. With the BGT water of water_path, see Water, Junctions are put on the water, see junctions_onto_water, and kept there when they are moved apart, both within the area of their Basin, see junction_areas. The links of the nodes that are moved go straight to them from the distance of the move, see move_nodes, so they do not hook back to where a node was.