7

In QGIS 3.4.1 I had a vector layer stored in GeoPackage format with a text field ("lbl_text") that was being used to create labels on a map. After creating three points I decided it would be nice to rotate my labels, so I added a rotation field ("lbl_rotation"). This prompted multiple notifications stating that the rotation field already existed and that the changes could not be made. I could not save changes to the layer so I cancelled and discarded them.

Despite the rotation field not previously existing and the notifications that creating this field had failed, the rotation field was now present. So I linked it to the data defined rotation option under Properties > Labels > Rotation. Now my labels could be rotated using Label Toolbar > Rotate Label.

But when zooming in the point created after this event disappeared. I could not see any reason for this and checked for others having a similar issue. A common solution was to use the geometry checker, so I tried this and found no errors (they're all points after all, what could go wrong?).

Deleting the point and recreating it did not fix the issue. The 4th point created always disappeared when zoomed in, regardless of how many times it was deleted and recreated, or where on the map it was created.

I added a fifth point and it did not have this issue. Eventually I deleted all points and recreated them all. None of them had this issue.

Now all points on this layer exhibit the same problem behaviour, though they didn't when first posting about the issue.

Does anyone have any idea what might have happened and how to fix the problem?

Points when zoomed out.
example1

The same 3 points when zoomed in. One cannot be seen.
example2

6
  • I noticed that you said you copied the layer styles to replicate the problem. Can you confirm that there isn't a scale level set in the style which may be making points of a certain type not be visible? Also is there any chance of making the geopackage and style available for testing? Dec 5, 2018 at 0:19
  • 1
    Copying the style and pasting it to a new layer does not carry the problem forward. The problem exists only in the original layer. Using Right Click > Duplicate on the affected layer results in a new layer with the same problem. Using Right Click > Save As and saving as a new geopackage then adding that to the map results in a layer with no problem, and pasting the style to this layer results in a layer with the same style and no problem.
    – Sangster
    Dec 7, 2018 at 5:51
  • Properties > Rendering > Scale dependent visibility is unchecked although Properties > Labels > Rendering > Scale dependent visibility is configured to show labels when zoomed in. Disabling this for labels does not prevent the points from disappearing. GeoPackage here: link
    – Sangster
    Dec 7, 2018 at 6:00
  • Thanks for sharing the data. I'm at a loss to explain what is happening, I can see the behaviour you are referring to. I did save the layer out to a new GeoPackage layer and the issue does not occur in the new layer. The issue on the gpkg you provided might be related to how it was created or something that has happened to it in the meantime. Dec 10, 2018 at 2:24
  • I appreciate your time investigating this. It's helpful to have confirmation that the geopackage appears to have been corrupted when attempting to add a label rotation field after setting up the initial labels. We have global desktops and strange network events here so hopefully this is an isolated problem. I have not been able to reproduce it.
    – Sangster
    Dec 10, 2018 at 4:50

4 Answers 4

8

I've seen this happen with a out of date Spatial index file. Have look in the directory where the shapefile is and if there is a file with the same name as the shape file with a .qix extension try deleting it and then view the layer again in QGIS.

If you're not using a shapefile? You can try going into the layer Properties > Source > Create Spatial index, to recreate the index. As shown in image below.

enter image description here

4
  • Thanks for your help, in this case the data is stored in GeoPackage format.
    – Sangster
    Nov 25, 2018 at 22:41
  • Can you amend your question to contain that detail. It may help people recognize the problem if they have encountered it before and subsequently provide you with a solution. Nov 25, 2018 at 22:57
  • 1
    Clicking the Create Spatial Index button results in a message box saying it was successful, but the problem persists. I also tried the Update Extents button afterwards but don't see any changes. The question has been amended to include that the layer is in GeoPackage format.
    – Sangster
    Nov 26, 2018 at 4:49
  • Thank you, I needed to do this when importing lat/long from csv as well.
    – Scott
    Jan 2, 2022 at 16:22
1

@Sangster answered to his own question:

The following has recovered the project so has been noted to help others, but it does not identify or repair the original problem so I am not marking it as the answer. Note that simply duplicating the affected layer resulted in duplicating the problem too.

To recover from this problem:

  • Right click the affected layer and save as a new GeoPackage
  • Ensure Add saved file to map is checked or re-add the saved layer
  • Right click the affected layer and select Styles > Copy Style
  • Right click the new layer and select Styles > Paste Style
  • Delete the affected layer and rename the new one.
0

Reprojecting the layer may solve this problem

Encountered similar problem with a csv layer. The spatial index was already created while the file was added to the project and hence the Create Spatial Index option was greyed out. Removing and re-adding also did not help. Reprojecting the layer using solved the issue.

Reprojecting can be done using

Vector general > Reproject Layer

The target CRS can be same or different from the original CRS. Once the layer is reprojected then the styles may be copied. Now points won't disappear on zooming in.

-1

You need to save/export your layer to a new layer.

Right Click -> Export -> Save features as

You will not have the same problem in the new layer.

Your Answer

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

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