I am trying to clip streets by a layer with municipalities in them. I was trying to run this script in QGIS3 but obtain the error hereunder.
Traceback (most recent call last): File "C:\OSGEO4~1\apps\Python37\lib\code.py", line 90, in runcode exec(code, self.locals) File "", line 1, in File "", line 11, in File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\tools\general.py", line 105, in run return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context) File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\core\Processing.py", line 130, in runAlgorithm context = dataobjects.createContext(feedback) File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\tools\dataobjects.py", line 72, in createContext context.setFeedback(feedback) TypeError: QgsProcessingContext.setFeedback(): argument 1 has unexpected type 'str'
I tried to run the script in QGIS2 and it works perfectly (changing run to runalg off course).
I checked the documentation of clipping in PyQGIS3 but I can't figure out what I am doing wrong. I hope someone has some insights for me.
import processing streets = QgsVectorLayer(r"C:\Users\Me\Desktop\Test\\streets_fix.shp", "streets", "ogr") if not streets.isValid(): print("Layer failed to load!") municipalities= QgsVectorLayer(r"C:\Users\Me\Desktop\Test\municipalities.shp", "municipalities", "ogr") if not municipalities.isValid(): print("Layer failed to load!") processing.run("qgis:clip", municipalities, streets, r"C:\Users\Me\Desktop\Test\clipttest1.shp")