Skip to content

Commit

Permalink
add NoDataStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
JoostBuitink committed Jan 11, 2024
1 parent e3f313c commit 1dd7d8b
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions hydromt_wflow/wflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import xarray as xr
from dask.diagnostics import ProgressBar
from hydromt import flw
from hydromt.nodata import NoDataStrategy
from hydromt.models.model_grid import GridModel
from pyflwdir import core_conversion, core_d8, core_ldd
from shapely.geometry import box
Expand Down Expand Up @@ -1186,14 +1187,27 @@ def setup_gauges(
code = self.crs
kwargs.update(crs=code)
gdf_gauges = self.data_catalog.get_geodataframe(
gauges_fn, geom=self.basins, assert_gtype="Point", **kwargs
gauges_fn,
geom=self.basins,
assert_gtype="Point",
handle_nodata=NoDataStrategy.IGNORE,
**kwargs,
)
elif self.data_catalog[gauges_fn].data_type == "GeoDataFrame":
gdf_gauges = self.data_catalog.get_geodataframe(
gauges_fn, geom=self.basins, assert_gtype="Point", **kwargs
gauges_fn,
geom=self.basins,
assert_gtype="Point",
handle_nodata=NoDataStrategy.IGNORE,
**kwargs,
)
elif self.data_catalog[gauges_fn].data_type == "GeoDataset":
da = self.data_catalog.get_geodataset(gauges_fn, geom=self.basins, **kwargs)
da = self.data_catalog.get_geodataset(
gauges_fn,
geom=self.basins,
handle_nodata=NoDataStrategy.IGNORE,
**kwargs,
)
gdf_gauges = da.vector.to_gdf()
# Check for point geometry
if not np.all(np.isin(gdf_gauges.geometry.type, "Point")):
Expand Down Expand Up @@ -1688,7 +1702,10 @@ def _setup_waterbodies(self, waterbodies_fn, wb_type, min_area=0.0, **kwargs):
if "predicate" not in kwargs:
kwargs.update(predicate="contains")
gdf_org = self.data_catalog.get_geodataframe(
waterbodies_fn, geom=self.basins, **kwargs
waterbodies_fn,
geom=self.basins,
handle_nodata=NoDataStrategy.IGNORE,
**kwargs,
)
# skip small size waterbodies
if "Area_avg" in gdf_org.columns and gdf_org.geometry.size > 0:
Expand Down Expand Up @@ -1859,7 +1876,10 @@ def setup_glaciers(self, glaciers_fn="rgi", min_area=1):
# retrieve data for basin
self.logger.info("Preparing glacier maps.")
gdf_org = self.data_catalog.get_geodataframe(
glaciers_fn, geom=self.basins, predicate="intersects"
glaciers_fn,
geom=self.basins,
predicate="intersects",
handle_nodata=NoDataStrategy.IGNORE,
)
# skip small size glacier
if "AREA" in gdf_org.columns and gdf_org.geometry.size > 0:
Expand Down

0 comments on commit 1dd7d8b

Please sign in to comment.