2

I try to use native algorithm difference of QGIS. But it seams it doesn't work like the others :

parameters = {'INPUT': polygons['OUTPUT'], #from temporary layer created before
              'OVERLAY': layer, #read in the beginning with QgsVectorLayer
              'OUTPUT': 'memory:'}
differenced = processing.run('qgis:difference', parameters)

I get the following error :

_core.QgsProcessingException: There were errors executing the algorithm.

Both input and overlay layers have the same geometry. Any idea ?

1

I had similar problem and I found your question whilst searching for a solution. I see it's been five months though, so i guess you've found a solution already - if not, the script I use below works for me (i'm currently using QGIS 3.4.3).

A = QgsProject.instance().mapLayersByName('t_alpha')[0]
B = QgsProject.instance().mapLayersByName('t_beta')[0]

parameters = {'INPUT' : A, 'OVERLAY' : B, 'OUTPUT' : 'memory'}

results = processing.runAndLoadResults('qgis:difference', parameters)

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.