Click here to Skip to main content
14,237,457 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am creating a qgis python plugin in which I need to look for a string in the layer's name and if the string is found, then I need to get that layer's absolute path, and concatenate it with some strings and then the next absolute path.
I am then sending that concatenated string as a parameter for the Grid part of the function K-Means clustering for Grids, but I am getting an error that says:
"
Unable to execute algorithm, Incorrect parameter value for GRIDS".
How can I fix this error?
Thanks in advance.

What I have tried:

<pre>
    def pasos(self):
        sel=r""
        layers=[layer for layer in QgsProject.instance().mapLayers().values()]
        ar_len = len(layers)
        if(str(self.dlg.cb.currentText())=="K-Means Clustering for Grids"):
            for i in range(ar_len):
                if "01" in str(layers[i].name()):
                    if i==0:
                        abs = QgsProject.instance().readPath("./") + "/1_entradas/2_raster/" + layers[i].name() + ".tif"
                        sel +="'"+abs
                    else:
                        abs = QgsProject.instance().readPath("./") + "/1_entradas/2_raster/" + layers[i].name() + ".tif"
                        sel += "','"+abs
        sel += "'"
        print(sel)
        processing.run("saga:kmeansclusteringforgrids", {'GRIDS': [r''+sel],
        'METHOD': 1, 'NCLUSTER': 15, 'MAXITER': 0,
        'NORMALISE': True, 'OLDVERSION': False,
        'UPDATEVIEW': True, 'CLUSTER': 'TEMPORARY_OUTPUT',
        'STATISTICS': 'TEMPORARY_OUTPUT'})
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100