<div dir="auto">Hi, <div dir="auto"><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;line-height:inherit;font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:inherit;vertical-align:baseline;color:rgb(12,13,14);background-color:rgb(255,255,255)">I am trying to update a geometry using changeGeometryValues, it works fine when the layer is of type shp or geopakage, but when I use it in SpatialLite layer it gives me the following error.</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;line-height:inherit;font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:inherit;vertical-align:baseline;color:rgb(12,13,14);background-color:rgb(255,255,255)">This is part of the code that I use. How can I solve this error?</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;line-height:inherit;font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:inherit;vertical-align:baseline;color:rgb(12,13,14);background-color:rgb(255,255,255)">patialLite layer it gives me the following error.</p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;line-height:inherit;font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:inherit;vertical-align:baseline;color:rgb(12,13,14);background-color:rgb(255,255,255)">This is part of the code that I use. How can I solve this error?</p><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px">
feats1 <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> [ feat <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">for</span> feat <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">in</span> QgsProject.instance().mapLayersByName(<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">'trapecio_lineal'</span>)[<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">0</span>].getFeatures() ]
feats2 <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> [ feat <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">for</span> feat <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">in</span> QgsProject.instance().mapLayersByName(<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">'malezas_areal'</span>)[<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">0</span>].getFeatures() ]
tempLayer <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> QgsVectorLayer(<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">'Polygon?crs=EPSG:3795'</span>, <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">'templayer'</span>, <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">'memory'</span>)
dptemp <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> tempLayer.dataProvider()
feattemp <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> QgsFeature()
<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">for</span> feats_trapecio <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">in</span> feats1:
geom1 <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> feats_trapecio.geometry()
iter <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> feats_trapecio.geometry().vertices()
listOfVertices <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> []
while iter.hasNext():
vertex <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> iter.next()
listOfVertices.append([vertex.x(), vertex.y()])
poligonotrapecio <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> listOfVertices
points <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span>[]
<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">for</span> i <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">in</span> <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">range</span>(len(poligonotrapecio)):
point<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span>QgsPointXY(<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">float</span>(poligonotrapecio[i][<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">0</span>]), <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">float</span>(poligonotrapecio[i][<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">1</span>]))
points.append(point)
polig <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> QgsGeometry.fromPolygonXY([points])
feattemp.setGeometry(polig)
tempLayer.dataProvider().addFeatures([feattemp])
tempLayer.commitChanges()
geomtemplayer <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> feattemp.geometry()
<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">for</span> feats <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">in</span> feats2:
geom2 <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> feats.geometry()
fid <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> <a href="http://feats.id">feats.id</a>()
if geomtemplayer.intersects(geom2):
geom4 <span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">=</span> geom2.intersection(geomtemplayer)
QgsProject.instance().mapLayersByName(<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">'malezas_areal'</span>)[<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">0</span>].dataProvider().changeGeometryValues({fid: geom4})
QgsProject.instance().mapLayersByName(<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">'malezas_areal'</span>)[<span style="margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline">0</span>].commitChanges()
QgsProject.instance().addMapLayer(tempLayer)
QgsProject.instance().removeMapLayer(tempLayer.id())</code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;max-height:300px"><br></code></pre><pre style="margin-top:0px;padding:12px;border:0px;line-height:1.30769;font-size:13px;vertical-align:baseline;border-radius:5px;max-height:300px"><br></pre><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;line-height:inherit;font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:inherit;vertical-align:baseline;color:rgb(12,13,14);background-color:rgb(255,255,255)">This is the error that appears in the Qgis panel:</p><p style="margin:0px;padding:0px;border:0px;line-height:inherit;font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:inherit;vertical-align:baseline;color:rgb(12,13,14);background-color:rgb(255,255,255)">Error de SQLite: areas_verdes_y_terrenos.malezas_areal.GEOMETRY violates Geometry constraint [geom-type or SRID not allowed] SQL: UPDATE "areas_verdes_y_terrenos.malezas_areal" SET "geometry"=GeomFromWKB(?, 3795) WHERE "ogc_fid"=?</p><p style="margin:0px;padding:0px;border:0px;line-height:inherit;font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:inherit;vertical-align:baseline;color:rgb(12,13,14);background-color:rgb(255,255,255)"><br></p><p style="margin:0px;padding:0px;border:0px;line-height:inherit;font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:inherit;vertical-align:baseline;color:rgb(12,13,14);background-color:rgb(255,255,255)"><br></p><p style="margin-top:0px;margin-right:0px;margin-left:0px;padding:0px;border:0px;line-height:inherit;font-family:"helvetica neue",helvetica,arial,sans-serif;font-size:inherit;vertical-align:baseline;color:rgb(12,13,14);background-color:rgb(255,255,255)"> </p></div></div>