[Qgis-user] Using processing algorithms from the console in QGIS 3.0

Havard Tveite havard.tveite at nmbu.no
Thu Mar 22 01:20:48 PDT 2018


QgsApplication.processingRegistry().algorithms() does not
list grass7:v.to.rast.value (but grass7:v.to.rast is
there).

In QGIS 3, the following seems to work:

myres = processing.run("qgis:union", {'INPUT': "my_input", 'OVERLAY': 
"my_overlay", 'OUTPUT': "my_result"}, feedback=None)['OUTPUT']

processing.algorithmHelp("qgis:union") describes the
parameters of the algorithm.
Parameter names are case sensitive (at least on Ubuntu).

Håvard

On 21. mars 2018 17:46, Stephen Bosch wrote:
> Hello,
> 
> I am running QGIS 3.0.0 in Linux.
> 
> I'm trying to migrate some pyqgis code from 2.14 to 3.0 and discovering 
> the hard way that just about everything has changed :)
> 
> (Unfortunately, the docs haven't been updated yet and the API docs are 
> pretty sparse.)
> 
> Say I have this command, which worked in 2.x:
> 
> file_grid_r = processing.runalg("grass7:v.to.rast.value", grid_v, 0, 1, 
> extent, 0.008333, -1, 0.000100, None)['output']
> 
> processing.runalg() doesn't exist anymore, apparently it was replaced 
> with processing.run(). However, this:
> 
> file_grid_r = processing.run("grass7:v.to.rast.value", grid_v, 0, 1, 
> extent, 0.008333, -1, 0.000100, None)['output']
> 
> does not work as expected. In the PyCharm debugger, I receive this error 
> message:
> 
> sys:1: ResourceWarning: unclosed <socket.socket fd=3, 
> family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, 
> laddr=('127.0.0.1', 50386), raddr=('127.0.0.1', 40183)>
> 
> (If the command syntax is in fact correct, then perhaps the algorithm is 
> not accessible?)
> 
> My questions:
> 
>   * Is there up-to-date console documentation for the Processing toolbox
>     somewhere?
>   * How can I get a listing of the available algorithms in the same
>     format as in 2.x?
>   * How do I convert the algorithm calls (processing.runalg) from 2.x to
>     3.x?
> 
> 
> Thanks
> 
> Stephen
> 
> 
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
> 

-- 
Håvard Tveite
Faculty of Science and Technology, NMBU
Drøbakveien 31, POBox 5003, N-1432 Ås, NORWAY
Phone: +47 67231548   Web: http://www.nmbu.no



More information about the Qgis-user mailing list