CanFlood icon indicating copy to clipboard operation
CanFlood copied to clipboard

Run CanFlood in Batch

Open akhilk15 opened this issue 1 year ago • 4 comments

Hi, is there a way to automate multiple CanFlood runs in QGIS? We have over 20 flood rasters. We would like to explore if there is a way to run CanFlood for every raster in batch. Any suggestion would be helpful. Thanks!

akhilk15 avatar Jan 29 '24 18:01 akhilk15

Thank you for the question. The documentation has a short blurb on non-plugin capabilities here, but it's not very helpful. In summary, the plugin GUI is designed for building single model runs (not batch/bulk scripting); however, the underlying model architecture is designed for use in a python script (which facilitates more fancy bulk/batch runs). We don't have any documentation on this (you're the first person to ask about it) and it's been a while since I've touched this so I don't remember all the details, but some of the tutorials are set up as scripted runs for the tests. For example, here is a method to run tutorial 1 in a script.

For your specific question, it sounds like you are looking for damage estimates for 20 hazard events? (not risk... and the gui has some cap on the number of events if I remember). If this is something you only need to do a few times, I would suggest trying to run the models and generating values per asset ('res_per_asset') to get csv files of all the damages, then post-processing these to get whatever analysis you're looking for (maybe split the 20 events up into 2x10).

If you're still keen to run scripted CanFlood models, I can send you some more example code... but I'll warn you it's not very user-friendly (thats what the gui is for ;)

cefect avatar Jan 29 '24 21:01 cefect

adding enhancement label as a reminder to improve the documentation and add some examples for scripted models

cefect avatar Jan 29 '24 21:01 cefect

Hi Seth @cefect, thank you for your quick response! I will first check the example Python script and see if I can edit it for batch runs. We could also try to split the events as you suggested. We are aiming to get some damage assessment first and see the numbers. We might do the risk assessment later. The reason we have so many rasters is because we are assessing coastal flood hazard, rainfall flood hazard, and the joint events under a range of climates. It would be beneficial for us if you could share some more example codes. My email is [email protected]. Thanks so much! :)

akhilk15 avatar Jan 30 '24 16:01 akhilk15

Hi, I often have projects with 30-50 flood rasters and haven't had any issues. I typically have them grouped by scenario for risk, so no more than 15 per run. However, I just tried a batch of 30 all together through the GUI for an impact run and it seems to have worked fine. Were you getting some errors?

Btw, for the scenario batches, it's really easy to group them in the layer pane to toggle each set on or off and then use "select visible" in the Hazard Sampler tab. (just be sure you don't have other rasters on, like a base map)

David

lateLarch avatar Feb 01 '24 20:02 lateLarch