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

Stephen Bosch posting at vodacomm.ca
Fri May 26 10:13:27 PDT 2017


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,40.1165319957,-4.1833333969,3.6163546031"
>
> 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/20170526/8d07b76a/attachment.html>


More information about the Qgis-user mailing list