<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">https://pastebin.com/raw/Y9v51ZMq</a></div></div>