6

BACKGROUND:

When I have moved labels in the past (using the Move Label... button) QGIS has automatically edited the layer's attribute table by adding two fields, auxiliary_storage_labeling_positionx and auxiliary_storage_labeling_positiony. The layer thus carried those two fields (with the position values) into the future, even when used in other projects.

However, I recently came upon a situation where QGIS did not modify the layer's attribute table, and instead stored the two fields in the project (presumably in the .qgd file).

This occurs with both 3.22.11 and 3.26.3, where I have a Geopackage layer containing a single point. When I move the point's label, I am asked, as usual, to supply the primary key (as always, I select the fid). However, no change is made to the layer's attribute table. Instead, the label styling window (below) shows the fields as data-defined, and stored in the project.

enter image description here

Furthermore, the Layer Properties shows the two position fields, but highlighted in green (I presume the green color indicates project storage, rather than attribute table):

enter image description here

QUESTION:

Based on this earlier question, I now know how to convert the project location to the attribute table.

Furthermore, I can see advantages as well as disadvantages to storing this information in either the attribute table or the project.

But why is QGIS now defaulting the label position storage location to the project instead of the attribute table, and how can I get it to default to the attribute table?

2 Answers 2

10

I am not speaking on behalf of the QGIS Developer Team, but I think the team has changed the default behavior from storing the labels in the attribute table to storing the labels in the project instead to avoid forcing the user from adding extra fields in the attribute table and to speed up moving the labels as well as other operations.

Many users do not prefer adding new fields just to move or rotate the labels. However, if you still want to retain the old behavior, although not automatically, you can do that by adding two fields: Label_X and Label_Y for example, and do the following process:

  • Under the Labels Tab, go to Placement Tab → Data defined (Coordinate) → under X select Label_X field, and under Y select Label_Y field. Make sure that the Store data in the project option is not selected for both X and Y
  • Open the attribute table to see the Label_X and Label_Y fields.
  • From the Label menu bar select the Move Label to move the labels. You will notice that the attribute table mode changed to the edit mode and both Label_X and Label_Y stored the coordinates of the moving labels.

enter image description here

If you open the layer properties, you will notice that the Auxiliary Storage does not contain any information about the location of the adjusted labels.

enter image description here

1

Based on ahmadhanb's (correct) answer, I did some additional research, which I would like to report here. I reviewed the visual changelogs all the way back to 3.0. There (to my surprise), I found the following:

You do not need anymore to add dedicated fields in your datasource to change labels position, rotation, or...

...labels are only saved along with your project file in a .qgd sqlite database, or inside the .qgz zipped project file if you chose that format...

And for power users, the old way of having data defined fields in your datasource is still there. Just define them in the layer’s properties as before!'

So, the default method for storing label locations in the project has been around since 3.0 (released February, 2018). I've moved labels dozens of times since then, and I could swear that the locations were always stored in the attribute table during that time.

Anyway, the 3.0+ method provides users the flexibility of storing label locations in the project and/or in the attribute table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.