From 295387b345125e018dda2a97d3946802ca8e837c Mon Sep 17 00:00:00 2001 From: rosepearson Date: Tue, 10 Sep 2024 09:57:48 +1200 Subject: [PATCH] Fixed issue when adding multiple rivers to the same DEM --- src/geofabrics/dem.py | 7 +++++++ src/geofabrics/processor.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/geofabrics/dem.py b/src/geofabrics/dem.py index cfff81bf..c46bbfe0 100644 --- a/src/geofabrics/dem.py +++ b/src/geofabrics/dem.py @@ -1257,11 +1257,18 @@ def interpolate_rivers( region_to_rasterise.dissolve().buffer(self.catchment_geometry.resolution), drop=True, ) + self._write_netcdf_conventions_in_place(edge_dem, self.catchment_geometry.crs) + edge_dem["z"] = edge_dem.z.rio.interpolate_na(method="nearest") + edge_dem = self._dem.rio.clip( + region_to_rasterise.dissolve().buffer(self.catchment_geometry.resolution), + drop=True, + ) edge_dem = edge_dem.rio.clip( region_to_rasterise.dissolve().geometry, invert=True, drop=True, ) + # Define the river and mouth edge points grid_x, grid_y = numpy.meshgrid(edge_dem.x, edge_dem.y) flat_x = grid_x.flatten() diff --git a/src/geofabrics/processor.py b/src/geofabrics/processor.py index 18e5c4e6..0816c925 100644 --- a/src/geofabrics/processor.py +++ b/src/geofabrics/processor.py @@ -1289,7 +1289,7 @@ def add_hydrological_features( ), cache_path=temp_folder, ) - temp_file = temp_folder / "dem_added_rivers.nc" + temp_file = temp_folder / f"dem_added_{index + 1}_rivers.nc" self.logger.info( f"Save temp DEM with rivers added to netCDF: {temp_file}" )