diff --git a/python/ribasim/ribasim/config.py b/python/ribasim/ribasim/config.py index 30d4f17d6..905d0387f 100644 --- a/python/ribasim/ribasim/config.py +++ b/python/ribasim/ribasim/config.py @@ -189,6 +189,9 @@ def __init__( ) -> None: if geometry.is_empty: raise (ValueError("Node geometry must be a valid Point")) + elif geometry.has_z: + # Remove any Z coordinate, this will cause issues connecting 2D and 3D nodes + geometry = Point(geometry.x, geometry.y) super().__init__(node_id=node_id, geometry=geometry, **kwargs) def into_geodataframe(self, node_type: str, node_id: int) -> GeoDataFrame: diff --git a/python/ribasim/tests/test_io.py b/python/ribasim/tests/test_io.py index 7c2dcf7b7..62bd01014 100644 --- a/python/ribasim/tests/test_io.py +++ b/python/ribasim/tests/test_io.py @@ -116,8 +116,10 @@ def test_extra_spatial_columns(): Node(1, Point(0, 0), meta_id=1), [basin.Profile(area=1000.0, level=[0.0, 1.0]), basin.State(level=[1.0])], ) + node = Node(2, Point(1, 0.5, 3.0), meta_id=2) + assert not node.geometry.has_z model.user_demand.add( - Node(2, Point(1, 0.5), meta_id=2), + node, [ user_demand.Static( demand=[1e-4], return_factor=0.9, min_level=0.9, priority=1