Does anyone know why when I’m editing my polygon (geojson) that the vertices return back to the original spot. I add them through a python script with QgsProject.instance().addMapLayer(). I start an edit mode, move the vertex, then go move the next vertex and then first vertex moves goes back to its original position. When I add the layer ( created from the python script) manually from the file explorer, I can edit the shape as expected. I tried running my code directly in the QGIS python console and the editing works as expected. So I know it has something to do with running the script from the Processing Toolbox -> Scripts.
In the image below you can see the red outline of the original polygon when I hover over the shape. So what I did was moved vertex from (1) to (2) (which works) but then when I go to move my next vertex it still uses the old shape and when I move another vertex it will move the original back .
Even with this simple code. I still get the same bug.
from qgis.PyQt.QtCore import (QCoreApplication, QVariant)
from qgis.core import (QgsProcessing,
QgsFeatureSink,
QgsProcessingException,
QgsProcessingAlgorithm,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsProcessingParameterString,
QgsProcessingParameterField,
QgsProcessingParameterBoolean,
QgsProcessingParameterFolderDestination,
QgsProcessingParameterFile,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterEnum,
QgsVectorLayer,
QgsProject,
QgsVectorDataProvider,
QgsDistanceArea,
QgsField,
QgsUnitTypes,
QgsVectorFileWriter)
from qgis.core import QgsProcessing
from qgis.core import QgsProcessingAlgorithm
from qgis.core import QgsProcessingMultiStepFeedback
from qgis.core import QgsProcessingParameterFile
class CheckGcpPoints(QgsProcessingAlgorithm):
def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFile('input_csv', 'Properties CSV', behavior=QgsProcessingParameterFile.File))
#self.addParameter(QgsProcessingParameterBoolean('thermal_parameter', 'Thermal', defaultValue=False))
# Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the
# overall progress through the model
def processAlgorithm(self, parameters, context, model_feedback):
registry = QgsProject.instance()
# Define qgis instance
# # Create Property layer
property_layer = QgsVectorLayer(parameters['input_csv'],'Properties')
registry.addMapLayer(property_layer)
results = {}
return ()
def name(self):
return 'PropertyEstimates2'
def displayName(self):
return 'Property Estimates2'
def group(self):
return 'SITE scripts'
def groupId(self):
return 'SITE scripts'
def createInstance(self):
return CheckGcpPoints()
Another case with Points.
You can see that I moved the point to the right, but when I try to move it again the point is still in the original place. I have to hover with my mouse to see the red original vertex as if the point didnt really move.