<div dir="ltr"><div>It has come to my attention that a few of the plugins that create memory layer polygons do not work correctly with the Geoprocessing Tools such as Difference. Two examples include the "New Memory Layer" plugin (which is being replaced by core) and my own Shape Tools plugin. I'm sure that others out there have the same problem. What happens is that when you create the polygons with these tools and you run the Geoprocessing algorithms such as the Difference operator, you get features back that do not contain the proper output polygons.</div><div><br></div><div>My question is how do I create these polygons to be valid to the new Geoprocessing algorithms? Currently I do the following:</div><div><br></div><div><table class="gmail-m_327041085091658843m_8287713516171879065gmail-highlight gmail-m_327041085091658843m_8287713516171879065gmail-tab-size gmail-m_327041085091658843m_8287713516171879065gmail-js-file-line-container"><tbody><tr><td class="gmail-m_327041085091658843m_8287713516171879065gmail-blob-code gmail-m_327041085091658843m_8287713516171879065gmail-blob-code-inner gmail-m_327041085091658843m_8287713516171879065gmail-js-file-line" id="gmail-m_327041085091658843m_8287713516171879065gmail-LC355">polygonLayer <span class="gmail-m_327041085091658843m_8287713516171879065gmail-pl-k">=</span> QgsVectorLayer(<span class="gmail-m_327041085091658843m_8287713516171879065gmail-pl-s"><span class="gmail-m_327041085091658843m_8287713516171879065gmail-pl-pds">"</span>Polygon?crs=ep<wbr>sg:4326<span class="gmail-m_327041085091658843m_8287713516171879065gmail-pl-pds">"</span></span>, "Layer Name", <span class="gmail-m_327041085091658843m_8287713516171879065gmail-pl-s"><span class="gmail-m_327041085091658843m_8287713516171879065gmail-pl-pds">"</span>memory<span class="gmail-m_327041085091658843m_8287713516171879065gmail-pl-pds">"</span></span>)</td>
      </tr>
      <tr>
        </tr></tbody></table>        ppolygon <span class="gmail-m_327041085091658843m_8287713516171879065gmail-pl-k">=</span> polygonLayer.dataProvider()</div><div>...</div><div><table class="gmail-m_327041085091658843m_8287713516171879065gmail-highlight gmail-m_327041085091658843m_8287713516171879065gmail-tab-size gmail-m_327041085091658843m_8287713516171879065gmail-js-file-line-container"><tbody><tr><td class="gmail-m_327041085091658843m_8287713516171879065gmail-blob-code gmail-m_327041085091658843m_8287713516171879065gmail-blob-code-inner gmail-m_327041085091658843m_8287713516171879065gmail-js-file-line" id="gmail-m_327041085091658843m_8287713516171879065gmail-LC398"> featureout <span class="gmail-m_327041085091658843m_8287713516171879065gmail-pl-k">=</span> QgsFeature()</td>
      </tr>
      <tr>
        </tr></tbody></table><table class="gmail-m_327041085091658843m_8287713516171879065gmail-highlight gmail-m_327041085091658843m_8287713516171879065gmail-tab-size gmail-m_327041085091658843m_8287713516171879065gmail-js-file-line-container"><tbody><tr><td class="gmail-m_327041085091658843m_8287713516171879065gmail-blob-code gmail-m_327041085091658843m_8287713516171879065gmail-blob-code-inner gmail-m_327041085091658843m_8287713516171879065gmail-js-file-line" id="gmail-m_327041085091658843m_8287713516171879065gmail-LC399"><p>                featureout.setGeometry(QgsGeom<wbr>etry.fromPolygon([pts]))</p><p># pts is an array of QgsPoints of the polygon vertices</p></td>
      </tr>
      <tr>
        </tr></tbody></table><table class="gmail-m_327041085091658843m_8287713516171879065gmail-highlight gmail-m_327041085091658843m_8287713516171879065gmail-tab-size gmail-m_327041085091658843m_8287713516171879065gmail-js-file-line-container"><tbody><tr><td class="gmail-m_327041085091658843m_8287713516171879065gmail-blob-code gmail-m_327041085091658843m_8287713516171879065gmail-blob-code-inner gmail-m_327041085091658843m_8287713516171879065gmail-js-file-line" id="gmail-m_327041085091658843m_8287713516171879065gmail-LC400"></td>
      </tr>
      <tr>
        </tr></tbody></table>                ppolygon.addFeatures([featureo<wbr>ut])</div><div>...</div><div>polygonLayer.updateExtents()</div><div>QgsMapLayerRegistry.instance().addMapLayer(polygonLayer)</div><div><br></div><div>What needs to be different? One of my concerns is that the geoprocessing algorithms takes the data, executes, fails to generate proper results, and doesn't give the user any warning that the results may be wrong. I sure hope this is only a memory layer issue and not also an issue with loading data from files or databases.</div><div><br></div><div>Thanks,</div><div><br></div><div>Calvin<br></div></div>