[Qgis-user] Using processing and pyqgis standalone - troubleshooting problems

Stephen Bosch posting at vodacomm.ca
Mon May 29 06:37:22 PDT 2017


To try and get a useful error message, I attempted to use the processing
toolbox GUI to run the r.buffer algorithm (as in
file_buffer=processing.runalg("grass:r.buffer",file_grid_r,buffer_sizes,1,False,extent,0,None)['output'])
 using similar inputs.

The procedure fails. On the 'Log' tab, this error message appears:

> Algorithm r.buffer - Creates a raster map layer showing buffer zones
surrounding cells that contain non-NULL category values. starting...
>
> r.external
input="/tmp/processingb16daa62fcb94d849f9a63e8bbc25b68/43fe856db3554415bf72198f57873202/GRID.sdat"
band=1 output=tmp14960641285513 --overwrite -o
>
> g.region n=3.6163546031 s=-4.1833333969 e=40.1165319957 w=34.2834319957
res=0.008333
>
> r.buffer input=tmp14960641285513 distances="25" units=kilometers
output=output5a1c9f3f6bad429bb777c1bee553a685 --overwrite
>
> g.region raster=output5a1c9f3f6bad429bb777c1bee553a685
>
> r.out.gdal --overwrite -c createopt="TFW=YES,COMPRESS=LZW"
input=output5a1c9f3f6bad429bb777c1bee553a685
output="/tmp/processingb16daa62fcb94d849f9a63e8bbc25b68/0a511ee06bd04de4b01d5386d68d159a/output.tif"
>
> Cleaning up temporary files...
>
> Starting GRASS GIS...
>
> ERROR: is not a valid GRASS Location because PERMANENT Mapset is missing
>
> Exiting...
>
> Cleaning up temporary files...
>
> Starting GRASS GIS...
>
> ERROR: is not a valid GRASS Location because PERMANENT Mapset is missing
>
> Exiting...
>
> Converting outputs
>
> Loading resulting layers
>
>
> The following layers were not correctly generated.
>
> Buffer
>
> You can check the log messages to find more information about the
execution of the algorithm

This is at least an error message. Why doesn't processing.runalg return
this error message? Obscuring it makes troubleshooting impossible. Because
the error is not passed through to the python console, I cannot even be
sure whether the error that occurs when I use the processing toolbox GUI is
the same error that is occurring when I run processing.runalg, I'm just
guessing.

The processing.log file shows only lines like this:

ALGORITHM|2017-05-29
> 15:22:08|processing.runalg("grass7:r.buffer","/tmp/processingb16daa62fcb94d849f9a63e8bbc25b68/43fe856db3554415bf72198f57873202/GRID.sdat","25",1,False,"34.2834319957,40.1165319957,-4.1833333969,3.6163546031",0,None)
>

Kind regards

Stephen


On Fri, May 26, 2017 at 7:13 PM, Stephen Bosch <posting at vodacomm.ca> wrote:

> Hello,
>
> I'm running QGIS 2.18.3 on Gentoo Linux and I have adapted a pyqgis script
> to run standalone, mostly so that I can run it in an IDE and use the
> debugger. I'm using a combination of SAGA and GRASS algorithms in the
> script and handing layers back and forth.
>
> Consider this snippet of code:
>
> #import and buffer grid
>> file_grid=path+"Data/grid_map.shp"
>> grid_v = QgsVectorLayer(file_grid, "grid", "ogr")
>> QgsMapLayerRegistry.instance().addMapLayer(grid_v)
>> extent="34.2834319957 <(283)%20431-9957>,40.1165319957,-4.1833333969,3.
>> 6163546031 <(616)%20354-6031>"
>> file_grid_r=processing.runalg("saga:shapestogrid",grid_v,"
>> TENSION_KV",0,4,0,1,3,extent,0.008333,1,None)['GRID']
>> file_buffer=processing.runalg("grass:r.buffer",file_grid_r,
>> buffer_sizes,1,False,extent,0,None)['output']
>> buffer= QgsRasterLayer(file_buffer)
>> QgsMapLayerRegistry.instance().addMapLayer(buffer)
>>
>
> The issue is that the processing.runalg("grass:r.buffer".. returns a path
> that does not exist. It is as though it is generating the layer target
> name, but not actually writing the file. But there is also no error
> message, and nothing appears in the processing log. The error message
>
> ERROR 4: `/tmp/processing1bd9334de08f4c9abeb227e4b9f5a5d2/
>> e861d6518096485ca004a3efe2b9a9a8/output.tif' does not exist in the file
>> system,
>>
>
> and is not recognised as a supported dataset name.
>
> appears as soon as anything tries to use the output.tif layer.
>
> Note that it does not matter if I specify a target layer or not -- in
> neither case is it generated.
>
> The most frustrating aspect here is that there are no useful error
> messages I can use to determine what is actually going wrong here. I'd be
> grateful for any feedback or assistance.
>
> Stephen
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20170529/200edc00/attachment.html>


More information about the Qgis-user mailing list