Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. parameters = {'INPUT': QgsProcessingFeatureSourceDefinition(layer1.id(), True),
  2. 'OVERLAY': QgsProcessingFeatureSourceDefinition(layer2.id(), True),
  3. 'OUTPUT': 'memory:'}
  4. differenced = processing.run('qgis:difference', parameters)
  5.  
  6. QgsProject.instance().addMapLayer(layer1, False)
  7. QgsProject.instance().addMapLayer(layer2, False)
  8.  
  9. diff = processing.runalg("qgis:difference", layer1, layer2, False, None)
  10. result = processing.getObject(diff['OUTPUT'])
  11. # if you want to save it to file
  12. _writer = QgsVectorFileWriter.writeAsVectorFormat(result, 'output_layer.shp', "utf-8", None, "ESRI Shapefile")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement