I wrote a simple plugin to retrieve and synchronize points from remote MongoDb into a generated scratch layer with all the attributes every time the project open, edit and commit but the attribute naming bothering me for sometimes.
Scratch layer is in-memory layer that does not preserve the features upon exit. However I can save the project together with the layer.
Whenever I load the project, the attributes name of scratch layer gets appended with
:(0,0). E.g. the attribute changed from
Apparently it will only happened if the attributes created using python.
How to produce:
layer = iface.activeLayer() from PyQt4.QtCore import QVariant field = QgsField("test", QVariant.String) layer.dataProvider().addAttributes([field]) layer.updateFields()
- Create Temporary Scratch Layer
- Run the code above in Python Console
- Save the layer edit and project into a
- Exit and reopen QGIS
- Reopen the saved project file
- Open the layer Properties > Fields
- The attribute name
testwill turns into
I am using QGIS 2.18.2
I found that QGIS does not preserve the data type
string into the project file when the field created using python. The project file
.qgs xml content under
qgs > projectlayers > maplayer > datasource is:
but it should be: