[QGIS-Developer] Geoprocessing Tools Fail with Memory Layers

C Hamilton adenaculture at gmail.com
Fri Jan 5 11:03:41 PST 2018


I've asked about this several time and have never gotten a real response.
The following code creates two memory layer polygons that overlap.

from qgis.core import (QgsFeature,
    QgsVectorLayer, QgsPoint, QgsFeature,
    QgsMapLayerRegistry)

poly1 = QgsVectorLayer("Polygon?crs=epsg:4326", "Polygon 1", "memory")
dp = poly1.dataProvider()

pts = [QgsPoint(-117.9031, 44.4169), QgsPoint(-103.86080, 44.700146),
QgsPoint(-104.655656, 38.257599), QgsPoint(-117.9031, 44.4169)]
f = QgsFeature()
f.setGeometry(QgsGeometry.fromPolygon([pts]))
dp.addFeatures([f])
poly1.updateExtents()
QgsMapLayerRegistry.instance().addMapLayer(poly1)

poly2 = QgsVectorLayer("Polygon?crs=epsg:4326", "Polygon 2", "memory")
dp = poly2.dataProvider()

pts = [QgsPoint(-115.27676, 40.242037), QgsPoint(-101.32007, 41.387353),
QgsPoint(-102.1608432, 33.314810), QgsPoint(-115.27676, 40.242037)]
f = QgsFeature()
f.setGeometry(QgsGeometry.fromPolygon([pts]))
dp.addFeatures([f])
poly2.updateExtents()
QgsMapLayerRegistry.instance().addMapLayer(poly2)

>From the QGIS menu if you run the Geoprocessing tools such as Intersection
or Difference on the two polygons the algorithms fail to return the correct
results. Are memory layers no longer supported in QGIS or is this a bug in
the Processing code? In QGIS 14 this code works fine, but with QGIS 18.x
and QGIS 2.99 it fails.

Thanks,

Calvin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180105/72beec41/attachment-0001.html>


More information about the QGIS-Developer mailing list