console usage for qgis:lineintersection processing tool has been given as below

processing.runalg('qgis:lineintersections', input_a, input_b, field_a, field_b, output)

and i loaded a polyline layer onto qgis and executed following commands in console

layer = qgis.utils.iface.activeLayer()

provider = layer.dataProvider()

columns = provider.fields()


processing.runalg('qgis:lineintersections', layer, layer, id, id,'output' )

lineintersection tool is working properly when i use it directly in qgis, but i want to execute it in console for which i m getting error as below .......

Traceback (most recent call last): File "", line 1, in File "C:/PROGRA~1/QGISWI~1/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 71, in runalg alg = Processing.runAlgorithm(algOrName, None, *args) File "C:/PROGRA~1/QGISWI~1/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 317, in runAlgorithm if not param.setValue(args[i]): File "C:/PROGRA~1/QGISWI~1/apps/qgis-ltr/./python/plugins\processing\core\parameters.py", line 676, in setValue elif len(value) > 0: TypeError: object of type 'QgsField' has no len()

i think problem is with passing values in function

Can anyone give the solution?


I tried it out this code:

import processing

layer = qgis.utils.iface.activeLayer()

path = '/home/zeito/pyqgis_data/my_output.shp'

processing.runalg('qgis:lineintersections', layer, layer, None, None, path )

for this situation:

enter image description here

and it worked. You don't need the id's (see the error 'QgsField' has no len() where I think the problem is). On the other hand, I used one absolute path and the name of output file with its respective extension (*.shp).

| improve this answer | |

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.