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?
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:
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:
And if you only want the algorithm names, you can use:
for key, value in processing.algs.help.shortHelp.items():
print(key)
-
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 getError: Algorithm not found
andAttributeError: '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
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)
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
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
```
QgsProcessingProvider.algorithms()
. – Joseph Aug 16 '17 at 9:55from qgis.core import QgsProcessingProvider
andQgsProcessingProvider.algorithms()
I getTypeError: QgsProcessingProvider.algorithms(): first argument of unbound method must have type 'QgsProcessingProvider'
– axel_ande Aug 16 '17 at 18:49TypeError: qgis._core.QgsProcessingProvider represents a C++ abstract class and cannot be instantiated
– axel_ande Aug 17 '17 at 15:53