Solved: SAGA GIS 7.9.0 and 2.3.2 (in QGIS) input error “Error: Catchment Area” on the execution of LS Factor “saga_cmd ta_hydrology 22” and other algorithms

Fellow researchers and open-source GIS enthusiasts,

Welcome to my blog!

I’d like to start with a disclaimer – I may be a researcher of this very area but that doesn’t mean everything I do or write here will work for you, in your own desktop configurations and package versions. I have no responsibility if you lose data or mess up your installation. I also do not authorize any copies of my content.

Last week, we talked a little about using SAGA on Command Line. Today, I am discussing solutions to the problem “Error: Catchment Area” on SAGA GIS. Or “Error: your input raster”, or “Input layers do not have the same grid extent”.

About the error

I got this error in more than one SAGA algorithm, but I will use LS Factor tool to exemplify. This error is possible in many algorithms that use at least two raster inputs.

Let’s look into the LS Factor tool, ta_hydrology 22. I am using command line version saga_cmd (SAGA Command Line Interface - CLI) here, but this error is reproducible in other platforms.

saga_cmd ta_hydrology 22 -SLOPE <str> -AREA <str> [-LS <str>] [-CONV <str>] [-METHOD <str>] [-EROSIVITY <str>] [-STABILITY <str>]

I enter these two rasters as inputs:

saga_cmd ta_hydrology 22 -SLOPE slope.tif -AREA sca_teste.tif -LS saida.tif

My output is:

____________________________

   #####   ##   #####    ##
  ###     ###  ##       ###
   ###   # ## ##  #### # ##
    ### ##### ##    # #####
 ##### #   ##  ##### #   ##
____________________________

SAGA Version: 7.9.0 (64 bit)

____________________________
library path: D:[..]saga-7.9.0_x64\saga-7.9.0_x64\tools\
library name: ta_hydrology
library     : ta_hydrology
tool        : LS Factor
identifier  : 22
author      : O.Conrad (c) 2003
processors  : 4 [4]
____________________________

loading: slope

100%loading: sca_teste

100%Error: Catchment Area

Usage: saga_cmd ta_hydrology 22 [-SLOPE <str>] [-AREA <str>] [-LS <str>] [-CONV <str>] [-FEET <str>] [-METHOD <str>] [-EROSIVITY <double>] [-STABILITY <str>]
  -SLOPE:<str>          Slope
        Grid, input
  -AREA:<str>           Catchment Area
        Grid, input
  -LS:<str>             LS Factor
        Grid, output
  -CONV:<str>           Area to Length Conversion
        Choice
        Available Choices:
        [0] no conversion (areas already given as specific catchment area)
        [1] 1 / cell size (specific catchment area)
        [2] square root (catchment length)
        Default: 0
  -FEET:<str>           Feet Adjustment
        Boolean
        Default: 0
  -METHOD:<str>         Method (LS)
        Choice
        Available Choices:
        [0] Moore et al. 1991
        [1] Desmet & Govers 1996
        [2] Boehner & Selige 2006
        Default: 0
  -EROSIVITY:<double>   Rill/Interrill Erosivity
        Floating point
        Minimum: 0.000000
        Default: 1.000000
  -STABILITY:<str>      Stability
        Choice
        Available Choices:
        [0] stable
        [1] instable (thawing)
        Default: 0

So that is the error I got: “Error: Catchment Area” and then I got the usage printed as output.

The same error, on SAGA 2.3.2 on QGIS 3.16.4:

legenda QGIS 3.18

I haven’t found anything about this error online, having to fix it myself, so I might as well be the only person that has ever had this issue. But, in hopes this post may help somebody someday, here I am, writing about it.

This error happens with seemingly completely average and compatible raster grids – sometimes they have the same dimensions, sometimes even the same cell size, and in visualization, they look like their grids are matching. So why?

Are their grids matching? Ok, but are they reallyyy matching? To be a few centimeters off can trigger this issue, because the rasters are not technically over the same grid. This happens even if the difference is much smaller than the grid size. Do not trust your eyesight. Could you notice that these two rasters below are not on the same grid?

legenda QGIS 3.18 legenda QGIS 3.18

I know I couldn’t!

How does that even happen?

Imagine you have raster A and raster B, generated from the same dataset via different procedures…

Raster A is projected on an UTM fuse and has a cell size of 30 m. Its size is 3000x150.

Raster B is also projected on an UTM fuse and has a cell size of 30 m. Its size is also 3000x150.

But…

Raster A starts in X coordinate of 0.00000 and Raster B starts in X coordinate of 0.01800, probably because of some other algorithm you used. That means they are slightly off centered. That much is enough to cause a difference and to abort the execution of some SAGA algorithms.

To see the cell size, dimensions, and start and end coordinates for each raster on QGIS 3.16 and QGIS 3.18, go to Properties, Information tab.

Is this your issue, or do you have a different issue?

To test if that is the issue, I tried running the same algorithm with the same raster for both inputs, just to see if the error happened. I did this because the raster is aligned with itself, without a doubt. And it worked like a charm:

saga_cmd ta_hydrology 22 -SLOPE slope.tif -AREA slope.tif -LS saida.tif

The output was:

____________________________

   #####   ##   #####    ##
  ###     ###  ##       ###
   ###   # ## ##  #### # ##
    ### ##### ##    # #####
 ##### #   ##  ##### #   ##
____________________________

SAGA Version: 7.9.0 (64 bit)

____________________________
library path: D:[..]\saga-7.9.0_x64\saga-7.9.0_x64\tools\
library name: ta_hydrology
library     : ta_hydrology
tool        : LS Factor
identifier  : 22
author      : O.Conrad (c) 2003
processors  : 4 [4]
____________________________

loading: slope

100%loading: slope

100%

Parameters


Grid System: 12.5; 2420x 2114y; 448524.650800x 6740995.164300y
Slope: slope
Catchment Area: slope
LS Factor:
Area to Length Conversion: no conversion (areas already given as specific catchment area)
Feet Adjustment: false
Method (LS): Moore et al. 1991
Rill/Interrill Erosivity: 1.000000
Stability: stable


101%Saving grid: saida.tif...
Export GeoTIFF


Parameters


Grid System: 12.5; 2420x 2114y; 448524.650800x 6740995.164300y
Grid(s): 1 object (saida)
File: saida.tif
Creation Options:

Band 1

100%
100%okay

So, if that works for you, you know the problem is really in the second input raster.

How to solve this issue and run SAGA smoothly?

My favorite way to ensure the rasters are on the same grid is using gdal Warp (Reproject) from Processing Toolbox of QGIS 3.16 (qgis.org). Do the projection (or don’t, if you don’t need to), and choose the limits of the other input raster to crop your raster. This is important. Use the other raster, not a vector mask (such as a shapefile).

legenda QGIS 3.18

Choose between the several options of interpolation (I like bilinear).

Try the algorithm again with the resulting raster.

SAGA command line

saga_cmd ta_hydrology 22 -SLOPE slope.tif -AREA sca_warp.tif -LS saida.tif

The output is:

____________________________

   #####   ##   #####    ##
  ###     ###  ##       ###
   ###   # ## ##  #### # ##
    ### ##### ##    # #####
 ##### #   ##  ##### #   ##
____________________________

SAGA Version: 7.9.0 (64 bit)

____________________________
library path: D:[..]\saga-7.9.0_x64\saga-7.9.0_x64\tools\
library name: ta_hydrology
library     : ta_hydrology
tool        : LS Factor
identifier  : 22
author      : O.Conrad (c) 2003
processors  : 4 [4]
____________________________

loading: slope

100%loading: sca_warp

100%

Parameters


Grid System: 12.5; 2420x 2114y; 448524.650800x 6740995.164300y
Slope: slope
Catchment Area: sca_warp
LS Factor:
Area to Length Conversion: no conversion (areas already given as specific catchment area)
Feet Adjustment: false
Method (LS): Moore et al. 1991
Rill/Interrill Erosivity: 1.000000
Stability: stable


101%Saving grid: saida.tif...
Export GeoTIFF


Parameters


Grid System: 12.5; 2420x 2114y; 448524.650800x 6740995.164300y
Grid(s): 1 object (saida)
File: saida.tif
Creation Options:

Band 1

100%
100%okay

SAGA on QGIS 3.16.4

legenda QGIS 3.18

Done! Case closed, at least, for now.

And good luck! That fix always works for me, and I hope it works for you too!

Extras:

  • My input rasters have different cell sizes too.

In this case, I suggest filling the “Output file resolution in target georeferenced units [optional]” field in the Warp (Reproject) with the exact value of the cell size from the other raster and trying again.

  • In the Properties, Information panel from each raster, they both show the same extents. Should I try using Warp anyway or surely this is a different problem?

Yes, I think you should. Try using Warp (Reproject). Especially if your rasters are in geographic coordinates lat long, the number of digits shown may not be sufficient to show the differences between the two raster layers.

  • I tried the same raster as both inputs in the SAGA tool and it still returns the “usage” message.

I am afraid this means you most likely have a different problem, and the steps presented here may not work for you.

Luísa Vieira Lucchese
Luísa Vieira Lucchese
PhD Student

MSc., Eng.

Related