The runalg method does not return a layer. It returns a dict with the outputs of the algorithms. Keys are output names, values are paths to output objects
Hope this helps 2014-03-25 22:36 GMT+01:00 Eric Goddard <[email protected]>: > Alright, latest master (9e42c5b), with processing version > 2.0-20131120. Running a custom tool that consists of the following > code results in an error: > > ##dem=raster > ##radius=number 4 > ##lpf=output raster > > lpf = processing.runalg("saga:simplefilter", dem, 0, 0, radius, None) > > > An error has occured while executing Python code: > > Traceback (most recent call last): > File > "/home/eric/.qgis2/python/plugins/processing/gui/AlgorithmExecutionDialog.py", > line 256, in accept > self.finish() > File > "/home/eric/.qgis2/python/plugins/processing/gui/AlgorithmExecutionDialog.py", > line 281, in finish > Postprocessing.handleAlgorithmResults(self.alg, self, not keepOpen) > File "/home/eric/.qgis2/python/plugins/processing/gui/Postprocessing.py", > line 77, in handleAlgorithmResults > dlg = CouldNotLoadResultsDialog(wrongLayers, alg) > File > "/home/eric/.qgis2/python/plugins/processing/gui/CouldNotLoadResultsDialog.py", > line 41, in __init__ > self.setupUi() > File > "/home/eric/.qgis2/python/plugins/processing/gui/CouldNotLoadResultsDialog.py", > line 50, in setupUi > html = self.alg.getPostProcessingErrorMessage(self.wrongLayers) > File "/home/eric/.qgis2/python/plugins/processing/core/GeoAlgorithm.py", > line 520, in getPostProcessingErrorMessage > + layer.value + '\n' > TypeError: cannot concatenate 'str' and 'dict' objects > > > Python version: > 2.7.6 (default, Feb 26 2014, 12:07:17) > [GCC 4.8.2 20140206 (prerelease)] > > > QGIS version: > 2.3.0-Master Master, 9e42c5b > > Python path: ['/home/eric/.qgis2/python/plugins/processing', > '/usr/share/qgis/python', u'/home/eric/.qgis2/python', > u'/home/eric/.qgis2/python/plugins', '/usr/share/qgis/python/plugins', > '/usr/lib/python27.zip', '/usr/lib/python2.7', > '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', > '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', > '/usr/lib/python2.7/site-packages', > '/usr/lib/python2.7/site-packages/gtk-2.0', > '/usr/lib/python2.7/site-packages/wx-3.0-gtk2', > '/usr/share/qgis/python/plugins/fTools/tools', '/home/eric/Documents'] > > > Running the code in the console completes successfully. However, I'm > still unable to run a grass algorithm when the grass_region_parameter > and grass_region_cellsize_parameter are set to None. > > Thanks, > Eric > > On Mon, Mar 24, 2014 at 10:13 PM, Eric Goddard <[email protected]> wrote: >> Oops, my mistake. I have ##lrm=output raster in the header, but lpf = ... Is >> the only line in my code. >> >> I don't get the error message after changing lrm to lpf in the header. I do >> get another error message, but I think I broke my processing by trying to >> force an update. I'll test it tomorrow. Sorry about the confusion! >> >> Eric >> >> On Mar 22, 2014 5:06 PM, "Eric Goddard" <[email protected]> wrote: >>> >>> Ah, I didn't know a file could he specified without a path. Thanks for the >>> clarification! >>> >>> On Mar 22, 2014 4:37 PM, "Victor Olaya" <[email protected]> wrote: >>>> >>>> > 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. >>>> >>>> Not sure why this is happening. I will try to reproduce the error and >>>> see if it can be fixed >>>> Thanks for the report >>>> >>>> > >>>> > 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/... >>>> >>>> This is not a bug. If you do not enter a filename, the output will >>>> always go to a temporary file. The output folder that yu can set in >>>> the settings is the folder to be used when you enter a filename >>>> without a path (like "myfile.shp", but not "/home/myuser/myfile.shp"), >>>> not the folder to use for temporary files. >>>> >>>> Thanks again! _______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
