Source: https://hydrology.usu.edu/dtarb/giswr/2014/Exercise5.pdf