I'm new to PyQGIS
I'm trying to split selected features into another vector layer using the Split layer function
The code I have is:
area_layer = map.gpkg
fpath_v = C:/output dirctory/filename.gpkg
processing.run("native:splitvectorlayer", {'INPUT':QgsProcessingFeatureSourceDefinition(area_layer, selectedFeaturesOnly=True, featureLimit=-1, geometryCheck=QgsFeatureRequest.GeometryAbortOnInvalid),'FIELD':'Code','PREFIX_FIELD':False,'FILE_TYPE':0,'OUTPUT':'fpath_v '})
But this produces the following error:
File "C:\PROGRA~1\QGIS33~1.3\apps\Python39\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "<string>", line 28, in <module>
TypeError: QgsProcessingFeatureSourceDefinition(): arguments did not match any overloaded call:
overload 1: argument 1 has unexpected type 'QgsVectorLayer'
overload 2: argument 1 has unexpected type 'QgsVectorLayer'
overload 3: argument 1 has unexpected type 'QgsVectorLayer'
I'm not sure how to troubleshoot or go about fixing this
map.gpkg
will give a syntax error. And please specify where you make your selection. When you use only a filepath as the source, QGIS is not aware of any selection, it should be a selection made on aQgsVectorLayer
within the current project.