lutraconsulting / qgis-crayfish-plugin

Plotting and manipulating mesh data in QGIS.
http://www.lutraconsulting.co.uk/products/crayfish/
Other
62 stars 24 forks source link

Suggestion: support conversion of other flow direction formats #495

Open AlisterH opened 1 year ago

AlisterH commented 1 year ago

There are many programs which produce flow direction rasters, and almost every one seems to use a different convention. There are reasons why some of these programs would be used in preference to others. It is particularly strange to me that crayfish supports converting from PCRaster and SAGA, but not from GRASS, which is more reliably available in QGIS. I found that a simple edit to dir_map = {} meant I could convert from GRASS output instead of PCRaster output:

        dir_map = {
            2: (1e-7, 1),
            1: (diag, diag),
            8: (1, 1e-7),
            7: (diag, -diag),
            6: (1e-7, -1),
            5: (-diag, -diag),
            4: (-1, 1e-7),
            3: (-diag, diag)
        }

There are also input cells containing -2, -4, -6 and -8, where there is edge contamination. I'm not sure if they should be treated the same as 2, 4, 6 and 8, or ignored.

Since it is essentially only a list of numbers that needs to change to support different conventions, rather than having separate tools for converting inputs with different conventions to grib, you could have a single tool which allows to specify the convention. As a workaround, users could run some other tool (perhaps even just generating a VRT) to reclassify their input to match PCRaster or SAGA convention, but this isn't very accessible - users have to know what's going on and find out the convention that the different programs use.

AlisterH commented 1 year ago

Here are some other conventions I gleaned from the internet:

Taudem

4   3   2
5       1
6   7   8

Whitebox

64  128 1
32  0   2
16  8   4

RichDEM

2   3   4
1   0   5
8   7   6

PySheds

32  64  128
16      1
8   4   2

Others I haven't checked: LSDTopotools ?

AlisterH commented 1 year ago

As a workaround, users could run some other tool (perhaps even just generating a VRT) to reclassify their input to match PCRaster or SAGA convention, but this isn't very accessible - users have to know what's going on and find out the convention that the different programs use.

Of course, a user might actually have other reasons to convert from one flow direction format to another (e.g. to compare the output of different programs, or apply the same style to the output from different programs), so perhaps a separate tool to convert flow direction formats would be more useful.