[Qgis-developer] processing.runalg() issue with grass algorithms

Eric Goddard egoddard1010 at gmail.com
Sat Mar 22 10:47:30 PDT 2014

Hello again,

Still having issues with processing, QGIS master (942d5da) compiled
today. I have a script I wrote for GRASS that i'm trying to port over
to QGIS. I'm testing the first step to make sure it is going to work
before I write the whole thing; it consists of:

  1 ##dem=raster
  2 ##radius=number 4
  3 ##lrm=output raster
  5 lpf = processing.runalg("saga:simplefilter", dem, 0, 0, radius, None)

If I run this script, I get the following error:

Oooops! The following output layers could not be open
lrm: /tmp/processing/caa3afc6e3c6437893392b173985697c/lrm.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

The Log contains:

Algorithm local relief starting...
Converting outputs
Loading resulting layers
Algorithm local relief finished

If I run the same line in the python console, it works correctly:
>>> radius = 4
>>> lpf = processing.runalg("saga:simplefilter", "SR_50M_alaska_nad", 0, 0, radius, None)
>>> processing.load(lpf['RESULT'])

Results in the map being loaded.

Also, if I change the output folder in the processing settings to a
different location (in this case, tmp/processing in my home folder)
and run another algorithm in the python console, the RESULT key still
points to /tmp/processing/...

Any pointers on why the script doesn't run would be appreciated. I
didn't see an existing issue on hub.qgis.org regarding the output
folder issue, so it might be a new bug...


On Sun, Mar 16, 2014 at 1:21 AM, Eric Goddard <egoddard1010 at gmail.com> wrote:
> Hi all,
> I'm using QGIS 2.3-Master 64-bit, fa157b0 with GRASS 6.4.4svn on linux.
> When I pass a grass command to processing.runalg() without specifying
> an empty output because the region/cell size are invalid. For example,
> using the qgis sample data, if I run:
> lpf = processing.runalg("grass:r.neighbors", "SR_50M_alaska_nad", 0,
> 9, False, False, None, None, None, None)
> there is an output key in lpf that points to a tif, but that tif
> doesnt exist. Looking at the log, the above command is translated to:
> processing.runalg("grass:r.neighbors","/data/GIS/qgis_sample_data/raster/SR_50M_alaska_nad.tif",0,9,False,False,"None","0,1,0,1",0.0,None)
> If one runs the r.neighbors algorithm from the Processing Toolbox,
> leaving the region and cell size at the defaults (blank and 0.00)
> works correctly. How can a similar behavior be achieved  when running
> the command through processing.runalg()?
> And on a somewhat related note, when running a grass algorithm from
> the toolbox there is an option to select extent on canvas--can this be
> used in custom processing scripts?
> Thanks!
> Eric

More information about the Qgis-developer mailing list