<div dir="ltr"><div dir="ltr">Hi Gabriel,</div><div dir="ltr"><br></div><div dir="ltr">Does the result change if you first create a Python variable for storing your new layer?</div><div dir="ltr">I mean:<br><div><br></div><div><i><font face="monospace">referenceSource = create_scratch_reference_layer()<br></font></i></div><div><i><font face="monospace">snapper = QgsGeometrySnapper(referenceSource)</font></i><br></div><div><br></div><div>instead of:</div><div><i><br></i></div><div><i>snapper = QgsGeometrySnapper(</i></div><div><i>    referenceSource=create_scratch_reference_layer()</i></div><div><i>)</i></div><div><br></div><div>Regards,</div><div><br></div><div>Germán</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El jue, 19 oct 2023 a las 14:46, Gabriel De Luca via QGIS-Developer (<<a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello all,</div><div><br></div><div>  I am working with the QgsGeometrySnapper pyqgis class, and have a problem to snap to a reference layer which is created inside a function (and returned by it).</div><div><br></div><div>  The code shared at [1] prints:</div><div><br></div><div>result = <QgsGeometry: Polygon ((0.10000000000000001 -0.10000000000000001, 10.09999999999999964 0, 9.90000000000000036 10.09999999999999964, 0 10, 0.10000000000000001 -0.10000000000000001))><br></div><div><br></div><div>  Which means that the geomPolygon was not snapped to the reference layer.</div><div></div><div>  But, if uncomment the line 41, which adds the reference layer to the project, the code prints:</div><div><br></div><div>result = <QgsGeometry: Polygon ((0 0, 10 0, 10 10, 0 10, 0 0))></div><div><br></div><div>  So, for some reason, adding the reference layer to the project makes the snapper to work.</div><div><br></div><div>  I want to ask you if you know why is this happening. Maybe I need to add something to make it work consistently.</div><div><br></div><div><br></div><div>Regards,</div><div>Gabriel</div><div><br></div><div>[1] <a href="https://pastebin.com/raw/Y9v51ZMq" target="_blank">https://pastebin.com/raw/Y9v51ZMq</a></div></div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">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/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>-----------<br></div><div>   |\__  <br>(:>__)(<br>   |/    <br>Soluciones Geoinformáticas Libres                            <br><a href="http://geotux.tuxfamily.org/" target="_blank">http://geotux.tuxfamily.org/</a><br><a href="http://twitter.com/GeoTux2" target="_blank">https://twitter.com/GeoTux2</a></div><div><br></div><div><div><a href="http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo" target="_blank"><img src="http://gis.stackexchange.com/users/flair/4972.png"></a></div></div></div></div></div></div></div></div>