Dear forum,
As mentioned this was a priority-1 one issue and for the time being I managed to code a (ugly as hell) solution based on the answers and my initial thoughts, although I cant post the exact code yet (as soon as the project is finished I'm allowed to) the general flow goes like this:
- Read the inputs and get the max Free Surface and coords on the nodes that matched a Water depth > tolerance condition
- For each pixel on the high res DEM perform a Near neighbor search whithin a radius, using the nodes from step 1.
- Perform an Alpha-trimmed Mean with those nodes. Setting the alpha filters the infamous high nodes along with some artifacts.
- Perform a bool operation, basically, if Free surface>=DEM+tol, then if flooded value is set to 1, else 0.
- Write as a raster output. (bool one, 1-0 values)
- using a GIS tool perform a Raster>vector and then carefully clean some artificial ponds using a combination of Dissolve and buffer tools, could make the final trick (untested yet)
This procedure was done using a parallel implementation (multiprocess) in python to compensate the ugliness of the algorithm (optimization is the root of evil indeed...)
For the most critical case at my disposal (not the one shown in the attached),using 4 cores of my machine, and toping at 1.9 gb ram per process because RAM was a bottleneck, I was able to get my boolean flood raster from a 800k-nodes-Telemac result and a 12.8 gb 2x2 m DEM raster in ~20min.
The attached files shows the difference between Raw results from telemac (displayed in the postTelemac plugin and just one zoom as a blue line), HEC-RAS output in red (I believe was smoothed in some degree by a coworker) and the Vectorized output of the script in black (hence the "saw" shape in the line) for a smaller case at my disposal.
Other similar process tested:
Instead of the Kneighbor+Alpha_Trimmed_mean filter, I tried Interpolation (thin plate splines, linear and some RBF) which took almost 5-10x more time to execute with decent results and triangulation which was almost as fast as the final code but with poor results (much more "false-positives" flood zones).
regards,
José C. Díaz.