The idea for SplashTool was floating around, along with the key libraries needed for implementation. The project will be built using the Python programming language. Python provides efficient implementation through its extensive library ecosystem. Plus, as the standard scripting language in both QGIS and ArcGIS, it’s widely adopted in stormwater analysis.
It quickly became apparent that the analysis would rely on raster data. GDAL is ideal for reading and writing GeoTIFF files, while the core iterative analysis uses NumPy, which boasts a wealth of mathematical functions and high-speed computational capabilities.
The key parameters for the iteration include:
- Terrain elevation
- Water depth
- Cumulative outflow per cell throughout the iteration
A crucial aspect of the development is calculating the flow between cells from one iteration step to the next. After testing NumPy’s gradient function, I opted for a custom difference-based approach, where the flow between cells depends on the differences in absolute water levels between adjacent cells.
diff_sum = dy_up + dy_down + dx_up + dx_down
wl_flow = diff_sum / 4
# however, water flow cannot be more than
# the water level in the cell
wl_flow = np.where(wl_flow > self.wd, self.wd, wl_flow)
# update water level in the center cells
self.wd -= wl_flow
# add the outflow to flow accumulation raster
self.flowacc += wl_flow
The full iteration process is now detailed in the documentation.