<div dir="ltr"><div><div><div>Richard,<br><br></div>Thanks for verifying this. It appears that the bug is with 2.18 and is not in 2.99.</div><div><br></div><div>The wrong result that I get is dependent on the function run. I either get one of the original layers or no result.</div><div><br></div>Regards,<br><br></div>Calvin<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 6, 2018 at 3:19 AM, Richard Duivenvoorde <span dir="ltr"><<a href="mailto:rdmailings@duif.net" target="_blank">rdmailings@duif.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi Calvin,<br>
<br>
Confirmed here:<br>
<br>
- creating the two memory(!) layers using Calvin's python code, and<br>
running intersection returns one of the two polygons<br>
- saving the same layers to gpkg and run intersection just works<br>
(I thought that it would have something to do with OTF, but with or<br>
without it it returns wrong).<br>
<br>
Please create an issue for this.<br>
<br>
I adapted your code to run in 2.99, and then with me it seems to work:<br>
<a href="http://pix.toile-libre.org/?img=1515181793.png" rel="noreferrer" target="_blank">http://pix.toile-libre.org/?<wbr>img=1515181793.png</a><br>
<br>
The red part is the intersection?<br>
<br>
What kind of (wrong) result do you get?<br>
Maybe create an issue for it too, with some more screendumps with your<br>
result and the expected result?<br>
<br>
from qgis.core import QgsFeature, QgsVectorLayer, QgsPoint, QgsFeature<br>
<span class=""><br>
poly1 = QgsVectorLayer("Polygon?crs=<wbr>epsg:4326", "Polygon 1", "memory")<br>
dp = poly1.dataProvider()<br>
<br>
</span>pts = [QgsPointXY(-117.9031, 44.4169), QgsPointXY(-103.86080,<br>
44.700146), QgsPointXY(-104.655656, 38.257599), QgsPointXY(-117.9031,<br>
44.4169)]<br>
f = QgsFeature()<br>
f.setGeometry(QgsGeometry.<wbr>fromPolygonXY([pts]))<br>
dp.addFeatures([f])<br>
poly1.updateExtents()<br>
QgsProject.instance().<wbr>addMapLayer(poly1)<br>
<span class=""><br>
poly2 = QgsVectorLayer("Polygon?crs=<wbr>epsg:4326", "Polygon 2", "memory")<br>
dp = poly2.dataProvider()<br>
<br>
</span>pts = [QgsPointXY(-115.27676, 40.242037), QgsPointXY(-101.32007,<br>
41.387353), QgsPointXY(-102.1608432, 33.314810), QgsPointXY(-115.27676,<br>
40.242037)]<br>
f = QgsFeature()<br>
f.setGeometry(QgsGeometry.<wbr>fromPolygonXY([pts]))<br>
dp.addFeatures([f])<br>
poly2.updateExtents()<br>
QgsProject.instance().<wbr>addMapLayer(poly2)<br>
<br>
<br>
Regards,<br>
<br>
Richard<br>
<div><div class="h5"><br>
<br>
On 05-01-18 20:03, C Hamilton wrote:<br>
> I've asked about this several time and have never gotten a real<br>
> response. The following code creates two memory layer polygons that overlap.<br>
><br>
> from qgis.core import (QgsFeature,<br>
>     QgsVectorLayer, QgsPoint, QgsFeature,<br>
>     QgsMapLayerRegistry)<br>
>    <br>
> poly1 = QgsVectorLayer("Polygon?crs=<wbr>epsg:4326", "Polygon 1", "memory")<br>
> dp = poly1.dataProvider()<br>
><br>
> pts = [QgsPoint(-117.9031, 44.4169), QgsPoint(-103.86080, 44.700146),<br>
> QgsPoint(-104.655656, 38.257599), QgsPoint(-117.9031, 44.4169)]<br>
> f = QgsFeature()<br>
> f.setGeometry(QgsGeometry.<wbr>fromPolygon([pts]))<br>
> dp.addFeatures([f])<br>
> poly1.updateExtents()<br>
> QgsMapLayerRegistry.instance()<wbr>.addMapLayer(poly1)<br>
><br>
> poly2 = QgsVectorLayer("Polygon?crs=<wbr>epsg:4326", "Polygon 2", "memory")<br>
> dp = poly2.dataProvider()<br>
><br>
> pts = [QgsPoint(-115.27676, 40.242037), QgsPoint(-101.32007, 41.387353),<br>
> QgsPoint(-102.1608432, 33.314810), QgsPoint(-115.27676, 40.242037)]<br>
> f = QgsFeature()<br>
> f.setGeometry(QgsGeometry.<wbr>fromPolygon([pts]))<br>
> dp.addFeatures([f])<br>
> poly2.updateExtents()<br>
> QgsMapLayerRegistry.instance()<wbr>.addMapLayer(poly2)<br>
><br>
> From the QGIS menu if you run the Geoprocessing tools such as<br>
> Intersection or Difference on the two polygons the algorithms fail to<br>
> return the correct results. Are memory layers no longer supported in<br>
> QGIS or is this a bug in the Processing code? In QGIS 14 this code works<br>
> fine, but with QGIS 18.x and QGIS 2.99 it fails.<br>
><br>
> Thanks,<br>
><br>
> Calvin<br>
><br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> QGIS-Developer mailing list<br>
> <a href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a><br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
><br>
<br>
<br>
</blockquote></div><br></div>