0

I'm calling GRASS r.topidx from QGIS 2.2.0. I can get other tools to work on the DTM, for example r.watershed. But r.topidx I get the Oops message:

Oooops! The following output layers could not be open output: C:/Users/User/Documents/GIS DataBase/Gills/Terrain/TopIdx.tif The above files could not be opened, which probably indicates that they were not correctly produced by the executed algorithm Checking the log information might help you see why those layers were not created as expected This algorithm requires GRASS to be run. A test to check if GRASS is correctly installed and configured in your system has been performed, with the following result: GRASS seems to be correctly installed and configured

Looking at the log, I find: C:\PROGRA~1\QGISVA~1\bin>r.topidx input=tmp14037940151265 Output topographic index layer=Output topographic index layer1a269dc6704c40399e5421e3bc50f16e --overwrite Sorry is not a valid option Sorry is not a valid option Sorry is not a valid option Sorry, is not a valid parameter Sorry is not a valid option Sorry is not a valid option Sorry is not a valid option ERROR: Required parameter not set: (Output topographic index map)

But, as you can see from the Ooops (very annoying) message, the output file is set to /TopIdx.tif. which should be OK?

Any idea what might be going wrong here?

2 Answers 2

1

1) First, you need to consult the r.topidx command of GRASS GIS:

With GRASS GIS:

enter image description here

The command is

r.topidx input=avauffe@tests_divers output=test_topixd

2) same with QGIS

enter image description here

The processing log

ALGORITHM|Thu Jun 26 2014 20:45:33|processing.runalg("grass:r.topidx","/Users/Shared/avauffe.tif","202086.577,205625.414407,88411.048,90534.3504441",0,"/Users/Shared/test.tif")

From the help:

input = /Users/Shared/avauffe.tif"
GRASS_REGION_PARAMETER = "202086.577,205625.414407,88411.048,90534.3504441"
GRASS_REGION_CELLSIZE_PARAMETER = 0
Output topographic index layer =  /Users/Shared/test.tif"

If there is a problem, you will get the error message "Oops..."

To check:

When you use a GRASS command from processing, the processing Python module create first a batch file with the command, named "grass_batch_job.sh" (Linux, Mac OS X) or "grass_script.bat" (Windows) in the folder .../.qgis2/processing: :

enter image description here

Then it execute this command with the Python module subprocess ((Python script .../plugins/processing/algs/grass/GrassUtils.py)

What is the content of your batch file ?

The batch file with v.voronoi:

g.proj -c proj4="+proj=utm +zone=30 +ellps=intl +towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs"
v.in.ogr min_area=0.0001 snap=-1 dsn="/Users/Shared/telechargement/30_06_14/qgis-mac-2.4/QGIS_2.3-dev_SnoLeo.app/Contents/MacOS/../Resources/python/plugins/processing/tests/data" layer=points output=tmp1403985550269 --overwrite -o
g.region n=4458983.8488 s=4458921.97814 e=270855.745301 w=270778.60198 res=1
v.voronoi input=tmp1403985550269 output=output4973a4a8d42444ce8ac8de404e4b13b7   --overwrite
v.out.ogr -s -c -e -z input=output4973a4a8d42444ce8ac8de404e4b13b7 dsn="/var/folders/vu/vu099NovH-KZpE5TEa83BU+++TI/-Tmp-/processing/1b556bdecead4a11a31da2fc029aa67d" format=ESRI_Shapefile olayer=output type=auto
exit

comes from the script GrassUtils.py (line 353-392) to check if GRASS GIS is installed:

    def checkGrassIsInstalled(ignorePreviousState=False):
    if isWindows():
        path = GrassUtils.grassPath()
        if path == '':
            return 'GRASS folder is not configured.\nPlease configure \
                    it before running GRASS algorithms.'
        cmdpath = os.path.join(path, 'bin', 'r.out.gdal.exe')
        if not os.path.exists(cmdpath):
            return 'The specified GRASS folder does not contain a valid \
                    set of GRASS modules.\n' \
                    + 'Please, go to the Processing settings dialog, and \
                    check that the GRASS\n' \
                    + 'folder is correctly configured'

    if not ignorePreviousState:
        if GrassUtils.isGrassInstalled:
            return
    try:
        from processing import runalg
        result = runalg(
            'grass:v.voronoi',
            points(),
            False,
            False,
            '270778.60198,270855.745301,4458921.97814,4458983.8488',
            -1,
            0.0001,
            0,
            None,
            )
        if not os.path.exists(result['output']):
            return 'It seems that GRASS is not correctly installed and \
                configured in your system.\nPlease install it before \
                running GRASS algorithms.'
    except:
        s = traceback.format_exc()
        return 'Error while checking GRASS installation. GRASS might not \
            be correctly configured.\n' + s

    GrassUtils.isGrassInstalled = True

This function is called when there is a problem and the command cannot be executed -> your grass_script.bat

GRASS seems to be correctly installed and configured

A solution ?

Use GRASS GIS directly (an not GRASS GIS from QGIS via processing) or the GRASS plugin

5
  • thank you for your help, Gene. I'm afraid I can't make much of the batch file(grass_script.bat). It seems to do v.voronoi (interesting because it doesn't have a vector map...), then v.out.ogr before exit. Here are the last few lines: v.voronoi input=tmp1403875188278 output=outputda3368514b154679a42a978c8677a9e3 --overwrite v.out.ogr -s -c -e -z input=outputda3368514b154679a42a978c8677a9e3 dsn="C:\Users\User\AppData\Local\Temp\processing\8dea7a7970f942a8b4024dced0e5ce34" format=ESRI_Shapefile olayer=output type=auto exit Does this mean anything to you? Regards, John
    – user30578
    Commented Jun 27, 2014 at 13:24
  • This is the result of the test to know if GRASS is available (lines 353-365 of GrassUtils.py). This means that the command has not "worked". Why ? I don't know, sorry (I don't use Windows)
    – gene
    Commented Jun 28, 2014 at 13:40
  • You were kind enough to do a test on r.topidx for me; I wondered whether your batch file ("grass_batch_job_sh") ended in the same way that mine does, with the reference to v.voronoi followed by v.out.ogr followed by type=auto exit. Knowing that might help me diagnose the fault.
    – user30578
    Commented Jun 28, 2014 at 19:29
  • look above for the explanation of your result
    – gene
    Commented Jun 28, 2014 at 20:36
  • Hi Gene, sorry about that. As soon as I sent it I knew it was stupid. John
    – user30578
    Commented Jun 30, 2014 at 18:22
1

The answer seems to be that r.topidx works when called through the GRASS tools, which are available after selecting and loading the GRASS plugin. It is available, but does not work (for me) when called from the Processing Toolbox.

I found this confusing, because some GRASS routines do work when called from the Processing Toolbox.

To use r.topidx (and r.fill.dir), you MUST follow the instructions in the UserGuide/Manual to create a new GRASS mapset, import your DEM into it, and call r.fill.dir and then r.topix from the GRASS toolbox, opened by clicking the Open GRASS Tools icon in the GRASS toolbar. Then, it works.

I submit this answer to my own question in case other users find the same confusion.

Incidentally, the SAGA topographic wetness index module is an alternative which does not require the hassle of opening a special mapset.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.