Skip to content

Commit

Permalink
Fixed issue when adding multiple rivers to the same DEM
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepearson committed Sep 9, 2024
1 parent abaa24c commit 295387b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/geofabrics/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/geofabrics/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand Down

0 comments on commit 295387b

Please sign in to comment.