4

I've understood that the processing algs are going to be implemented in the master version of qgis. What is the best way to track the status of which algs that are implemented and the plan for the rest?

  • The QgsProcessingProvider class has an algorithms() function which returns a list of algorthims currently implemented. So if you're running QGIS 2.99, you could use QgsProcessingProvider.algorithms(). – Joseph Aug 16 '17 at 9:55
  • 1
    Allright, I tried that from qgis.core import QgsProcessingProvider and QgsProcessingProvider.algorithms() I get TypeError: QgsProcessingProvider.algorithms(): first argument of unbound method must have type 'QgsProcessingProvider' – axel_ande Aug 16 '17 at 18:49
  • Resulted in TypeError: qgis._core.QgsProcessingProvider represents a C++ abstract class and cannot be instantiated – axel_ande Aug 17 '17 at 15:53
8

I guess calling various methods from classes is still an ongoing development. As a workaround, you can use the following to return a help description (of what I can only assume are for the algorithms currently implemented). This help description is set in a dictionary containing the algorithm name and its explanation:

processing.algs.help.shortHelp

But it's a little hard to read:

Help description


But we can format it a little using:

 print("{" + "\n".join("{}: {}".format(k, v) for k, v in processing.algs.help.shortHelp.items()) + "}")

Which is clearer:

Formatted help


And if you only want the algorithm names, you can use:

for key, value in processing.algs.help.shortHelp.items():
    print(key)

Processing algorithms

  • Thanks alot @Joseph! Just what I was asking for. Is there any way to see which parameter each function require? I tried to run reprojectlayer simliar to the way that I did in QGIS 2.18: processing.run('qgis:reprojectlayer', 'C:/dev/in_file.shp', 'EPSG:4326', 'C:/dev/out_file.shp') Hence I then get Error: Algorithm not found and AttributeError: 'str' object has no attribute 'reportError' – axel_ande Aug 22 '17 at 5:00
  • @axel_ande - I think the help method I described only prints the descriptions of each algorithm that will be implemented (i.e. not currently). But can't confirm that. And I found there's quite a few methods which cannot be called from various classes, including finding out the parameters for each algorithm. Hopefully they'll fix it soon :) – Joseph Aug 22 '17 at 9:06
3

I figured out how to run the processing algorithms in qgis 2.99 it requires(?) a dict with the parameters, like this (qgis is changed to native):

parameters = = {'INPUT': 'C:/dev/inputfile.shp','TARGET_CRS': 'EPSG:4326','OUTPUT': 'C:/dev/outputfile.shp'}
processing.run('native:reprojectlayer', parameters)
3

For complementing Joseph's answer for his commentary in this post, equivalent to alglist method can be accomplished with following code:

L = (dir(processing.algs.qgis))

for item in L:
    if (any(x.isupper() for x in item)):
        print ('qgis:' + item.lower())

M = (dir(processing.algs.gdal))

for item in M:
    if (any(x.isupper() for x in item)):
        print ('gdal:' + item.lower())

N = (dir(processing.algs.saga))

for item in N:
    if (any(x.isupper() for x in item)):
        print ('saga:' + item.lower()) 

whose condensed result is:

qgis:addtablefield
qgis:aggregate
qgis:aspect
qgis:barplot
qgis:basicstatistics
qgis:boxplot
qgis:buffer
qgis:checkvalidity
qgis:concavehull
qgis:createattributeindex
qgis:createconstantraster
qgis:datasources2vrt
qgis:defineprojection
qgis:delaunay
qgis:deletecolumn
.
.
.
gdal:assignprojection
gdal:buffer
gdal:cliprasterbyextent
gdal:cliprasterbymask
gdal:clipvectorbyextent
gdal:clipvectorbymask
gdal:colorrelief
gdal:dissolve
gdal:executesql
gdal:gdalalgorithm
gdal:gdalalgorithmdialog
gdal:gdalalgorithmprovider
gdal:gdalutils
gdal:gridaverage
.
.
.
saga:sagaalgorithm
saga:sagaalgorithmbase
saga:sagaalgorithmprovider
saga:saganamedecorator
saga:sagautils
saga:splitrgbbands
3

To reproduce processing.alglist() of QGIS 2.18 in QGIS 3, one can write also:

def alglist():
  s = ''
  for i in QgsApplication.processingRegistry().algorithms():
    l = i.displayName().ljust(50, "-")
    r = i.id()
    s += '{}--->{}\n'.format(l, r)
  print(s)

alglist()

which results in:

Tessellate------------------------------------------->3d:tessellate
Aspect----------------------------------------------->gdal:aspect
Assign projection------------------------------------>gdal:assignprojection
Buffer vectors--------------------------------------->gdal:buffervectors
.
.
.
Wind exposition index-------------------------------->saga:windexpositionindex
Zonal multiple regression analysis (points and predictor grids)--->saga:zonalmultipleregressionanalysispointsandpredictorgrids
Zonal raster statistics------------------------------>saga:zonalrasterstatistics

```

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.