Deltares / hydromt_wflow

Wflow plugin for HydroMT
https://deltares.github.io/hydromt_wflow/
GNU General Public License v3.0
15 stars 13 forks source link

Error when using bounding box argument if not provided in EPSG:4326 #270

Open tuggegese opened 3 months ago

tuggegese commented 3 months ago

HydroMT-Wflow version checks

Reproducible Example

made available upon request, as the data for reproducing the error is too large.

Current behaviour

Error when using hydro data in epsg:32633

Desired behaviour

Follow the behaviour in the documentation (see description details)

Additional context

Hello all, I am currently switching from wflow.py to wflow.jl and I was trying to use the HydroMT-Wflow Package (v"0.5.1.dev0") for model creation. I created a data catalogue of a local area in EPSG:32633. When trying to create the model with:

hydromt build wflow "./wflow/sbmMuerz/Database/TestBuildMuerz" -r "{'bbox': [497000.0,5249000.0,566200.0,5295000.0]}" -i wflow_build.yml -d './wflow/sbmMuerz/Database/Muerz_Basedata.yml' -vv

I get an error message.

In the documentation it is written:

Note that in order to define the region, using points or bounding box, the coordinates of the points / bounding box should be in the same CRS than the hydrography data.

So I was assuming that everything should work as long as I use the same projection for all datasets and configurations. However, I found that in wflow.py the crs of the boundingbox is hardcoded to 4326. When setting the correct crs, the error does no occur (However, I get an error later on which I think is also related to the projection)

` elif "bbox" in region: bbox = region.get("bbox")

Original

        #geom = gpd.GeoDataFrame(geometry=[box(*bbox)], crs=4326)
        # Modified
        geom = gpd.GeoDataFrame(geometry=[box(*bbox)], crs=32633)
        print(geom.crs)`

Do you have any recommendations on how to work with other projections other than EPSG:4326? If you need additional information for reproducing the error, I can also send my data catalogue and all related files.

Best regards, Sebastian

hboisgon commented 3 months ago

Hi @tuggegese ! Thanks for posting this issue. You are right that the documentation is not clear enough here.

If you are building a wflow model based on hydrographic region kinds basin or subbasin, then your point or bounding bounding box location should be in the same CRS as your hydrograhpy data. Additionally, to avoid memory error in case your hydrography data covers a much larger domain than your model, you can either provide basin_index_fn or bounds argument to avoid loading the whole data in memory. If you are using bounds, the CRS should be the same as your hydrography data.

image

image

For wflow, we also allow to use the kinds geom and bbox but you have to be extremely careful with these! If you use geom or bbox, no basin delineation will be done by HydroMT ie your geom should be the exact basin shape or your bbox should contain all basins and their boundary (eg an island). So I strongly recommend that in your case, you use basin or subbasin to prepare wflow models.

image

But you are right that for kind bbox, the coordinates should still be 4326. We will update that.

You can check the HydroMT region doc for more information on choosing your region.

tuggegese commented 3 months ago

Hi @hboisgon,

thank you for your comprehensive answer! I was experimenting a bit more with the bbox region option. However, in the forcings creation step the process got terminated without any error message - probably due to some memory issue (although I used a quite small chunk size). I then switched to the basin option for which everything worked fine. When running the model, however, I get an error message attributed to the cyclic input series (i.e., the LAI): ERROR: LoadError: unsupported cyclic timeseries. I did not find an obvious difference to the merit_hydro example yet, which was able to run with the LAI. I guess I will figure it out though. When disabling the LAI option, the model is able to run through and produces quite good results without any calibration.

One question still remains. I was setting up the model with a total of 7 runoff gauges for which I also created sub-basins configured in the setup_gauges section. However, I also want to set up some gauges for which I have snow observations. For these gauges, I don't want sub-basin delineation or river snapping. I tried adding another setup_gauges section in the configuration file, but it seemed to overwrite my settings for the runoff gauges. Is there any possibility for adding another gauges file? If not, I think this would be quite a nice feature to have.

Best regards, Sebastian

hboisgon commented 3 months ago

Hi @tuggegese

Good to hear that with basin things worked better. Yes you can add several gauges at the same time in your wflow model. For this I point you towards our FAQ page: https://deltares.github.io/hydromt_wflow/latest/getting_started/faq.html

We actually should update the response a little as outlets now have their separate methods (setup_outlets)

image