Tutorial: Calculate time of concentration of a river (Kirpich equation)
6. Calculate the time of concentration in PyQGIS
Because there's no easy way to calculate the Kirpich equation with
the field calculator in the attribute table, we're going to develop a
PyQGIS script in this section to implement the Kirpich equation
The Kirpich equation:
tc = k * (dx ** const1) * (S ** const2)
Where:
tc
= time of concentration in minutesk
= 0.0195 to convert to SI unitsdx
= distance between the first and last node in metersS
= the elevation difference between the first and last node in m/mconst1
= 0.77const2
= -0.385
Now you'll see the Python console appearing at the bottom of the screen.
2. Click the Show Editor icon .
This opens the editor where we can write code. A free tutorial to start learning PyQGIS can be found here.
3.
Write the code from the screenshot below. The lines with # give and
explanation. Alternatively you can download the script from GitHub.
4. Click the button and save the script as Kirpich.py
5. Click to run the script
You'll see the results in the Python console:
The concentration time is 21.8 minutes.