1

This is the code:

import processing

file1= QgsVectorLayer("/qgis_data/file1.shp",  "file1", "ogr")

file2= QgsVectorLayer("/qgis_data/file2.shp",  "file2", "ogr")
inte=processing.runAndLoadResults("saga:intersect", file1, file2)

But it gives:TypeError: argument of type 'QgsVectorLayer' is not iterable and if i skip it and proceed to the next part where I have to do a dissolve.

dissolved=QgsGeometryAnalyzer().dissolve(inte, "test_dissolved.shp", onlySelectedFeatures=False,
uniqueIdField=-1, p=None

it says:

NameError: name 'QgsGeometryAnalyzer' is not defined

(of course i have tried other variable since inte didn't exist- i used one of the files).

There are also functions that have changed in QGIS3 where I am working with and I have replaced as much as I could find on the internet. But these problems remain(the dissolve one for example has changed but can't find the new one).

Can you tell how to solve the problems and make the code work?

1

This should be

file1= QgsVectorLayer("/qgis_data/file1.shp",  "file1", "ogr")
file2= QgsVectorLayer("/qgis_data/file2.shp",  "file2", "ogr")
results=processing.runAndLoadResults("saga:intersect", {'A':file1, 'B':file2,'RESULT':'path_for_created_file.shp'})

Regarding QgsGeometryAnalyzer - if you look in the API break documentation, this class was removed in 3.0. The corresponding processing algorithms should be used instead.

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.