Skip to content

Commit

Permalink
Update setup_gauges docs #198
Browse files Browse the repository at this point in the history
  • Loading branch information
hboisgon committed Dec 14, 2023
1 parent 42ba639 commit 34a44b5
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions hydromt_wflow/wflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def setup_gauges(
):
"""Set a gauge map based on ``gauges_fn`` data.
Supported gauge datasets include "grdc"
Supported gauge datasets include data catlog entries, direct GeoDataFrame
or "<path_to_source>" for user supplied csv or geometry files
with gauge locations. If a csv file is provided, a "x" or "lon" and
"y" or "lat" column is required and the first column will be used as
Expand Down Expand Up @@ -1132,8 +1132,9 @@ def setup_gauges(
Parameters
----------
gauges_fn : str, Path, gpd.GeoDataFrame, optional
Known source name or path to gauges file geometry file, by default None.
gauges_fn : str, Path, gpd.GeoDataFrame
Catalog source name, path to gauges file geometry file or
geopandas.GeoDataFrame.
* Required variables if snap_uparea is True: ["uparea"]
index_col : str, optional
Expand Down Expand Up @@ -1191,16 +1192,21 @@ def setup_gauges(
gdf_gauges = self.data_catalog.get_geodataframe(
gauges_fn, geom=self.basins, assert_gtype="Point", **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
)
elif self.data_catalog[gauges_fn].data_type == "GeoDataset":
da = self.data_catalog.get_geodataset(gauges_fn, geom=self.basins, **kwargs)
gdf_gauges = da.vector.to_gdf()
# Check for point geometry
if not np.all(np.isin(gdf_gauges.geometry.type, "Point")):
raise ValueError(f"{gauges_fn} contains other geometries than Point")
elif gauges_fn in self.data_catalog:
if self.data_catalog[gauges_fn].data_type == "GeoDataFrame":
gdf_gauges = self.data_catalog.get_geodataframe(
gauges_fn, geom=self.basins, assert_gtype="Point", **kwargs
)
elif self.data_catalog[gauges_fn].data_type == "GeoDataset":
da = self.data_catalog.get_geodataset(
gauges_fn, geom=self.basins, **kwargs
)
gdf_gauges = da.vector.to_gdf()
# Check for point geometry
if not np.all(np.isin(gdf_gauges.geometry.type, "Point")):
raise ValueError(
f"{gauges_fn} contains other geometries than Point"
)
else:
raise ValueError(
f"{gauges_fn} data source not found or \
Expand Down

0 comments on commit 34a44b5

Please sign in to comment.