TransWikia.com

Creating cumulative friction map

Geographic Information Systems Asked by Carter Rucker on April 9, 2021

I am looking at bottom friction (Manning’s n) values in relation to storm surge as large volumes of water flow over a surface.

In order to calculate total head loss occurring as water passes from the original water’s edge to the final flooding extent, I must somehow figure out a way to account for cumulative losses. Is there a way I can create a raster map containing the cumulative (or average) Manning’s n values over which the water has traveled?

In other words, with the accumulation of friction starting from the original water’s edge, the first cell would contain its own Manning’s n value (I will call this n1). Moving away from the water’s edge, the next cell will be n1+n2. The next cell away from the water will be n1+n2+n3 and so on.

Below is a script I have created for making a cumulative Manning’s n map for a small (121-cell) sample raster of Manning’s values. The sample raster is named manningWithWater and this is done using r.buffer. The buffer starts from the raster called falseWater, which is artificial water values I have added to the Manning’s raster. The script works but is inefficient; this took 22 seconds on my tiny sample raster and would use up quite a bit of memory while processing a regularly-sized raster.

import grass.script as grass

def main():
    x = range(100,700,50)
    numString = ""
    for num in x:
        numString = numString + str(num) + ","
    numString = numString[:-1]
    grass.run_command('r.buffer',
        overwrite=True,
        input="falseWater@PERMANENT",
        output="falseWaterBuffer",
        distances=numString,
        units="feet")
    totalBuffers=grass.read_command('r.describe',
        map="falseWaterBuffer")
    maxBuffer=int(totalBuffers.split("-")[-1])
    finalExpression=""
    for n in range(2,maxBuffer+1):
        grass.mapcalc(
            "$output=if($buffer==$bandNumber,$manningWithWater,null())",
            overwrite=True,
            buffer="falseWaterBuffer@PERMANENT",
            output="band"+str(n),
            bandNumber=n,
            manningWithWater="manningWithWater@PERMANENT")
        grass.run_command('r.grow.distance',
            overwrite=True,
            input="band{0}@PERMANENT".format(n),
            value="band{0}Grown".format(n))
        grass.mapcalc(
            "$output=if($buffer>=$bandNumber,$bandGrown,0)",
            overwrite=True,
            output="band{0}Add".format(n),
            buffer="falseWaterBuffer@PERMANENT",
            bandNumber=n,
            bandGrown="band{0}Grown@PERMANENT".format(n))
        finalExpression=finalExpression+"band{0}Add@PERMANENT+".format(n)
    finalExpression=finalExpression[:-1]
    grass.mapcalc(
        "cumulativeN={0}".format(finalExpression),
        overwrite=True)

if __name__ == '__main__':
    main()

One Answer

r.watershed has a flow input and an accumulation output. Pass in the manning raster for flow and the accumulation will be the "cumulative ... Manning's n values over which the water has traveled" that you seek. You can run it a second time with no flow input, and then accumulation is the number of cells. You can use that to get the average n value.

Answered by mankoff on April 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP