6

I am working in QGIS 2.18.3.

I have a shape layer with point geometry, which I filter by some field, and then I work on its attribute table. Once I am done for the day, I save the project so I can continue the next day.

I store data on my computer, where nobody else connects to it, I do close the project afterwards, and finally I do switch off my computer.

Here is my shapefile with no filter (can be edited), shapefile unfiltered

then my shapefile after I applied the filter (still can be edited). shapefile filtered

But every day, when I open the project, I find the shapefile can not be edited, so I have to un-filter it and then save it with another name, delete de previous one and keep on working on the new one which allows me now to keep on editing.

I have tried duplicating the layer, but the duplicate is still non-editable.

Why does this happen? Is it a consequence of saving the project with a filtered shapefile?

  • Perhaps tell us a bit more about your process. When you save the project, do you close the project afterwards? Do you leave it open on your computer? Where is your data stored? Does anyone else have access to this data who may be connecting to it, and thus putting a lock on it? You say that you have to create a new layer. Have you tried adding that layer alone into a new instance of QGIS to see if it is editable then? There are a lot of variables here, so some more detail may help narrow the issue down a bit. – Get Spatial Mar 7 '17 at 8:31
  • 1
    my coworkers and I had a similar problem, shapelayers that I created couldn't be edited by them unless they saved them in their own directory, the same with Qgis-Project files they could edit it but not overwrite the original file, so they have to save them aswell. I guess it's a bug in Qgis because all of the above worked just fine till Qgis 2.16. – Andreas Mar 7 '17 at 8:32
  • I have the same problem. I usee SpatiaLite rather than SHP format. After saving the project file with the layer (SPatiaLite) filtered and closing it - the layer becomes a non-editable for some reasons. The next session shows the layer but the Toggle Editing tool remains grey. One unfiltered and the project restarted - the layer becomes editable again. Quite annoying to be honest. Can you advise? – Maciek Drozda Feb 9 '18 at 14:27
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – pLumo Feb 9 '18 at 15:11
9

QGIS disables editing of filtered shapefiles for the sake of data safety. Remember that shapefiles use an outdated dbase storage format, with little effort to allow keeping track of data integrity.

If you need filtering and editing, think of another file format. I have switched to using spatialite databases for that purpose. The sqlite database system is capable of filtering, and keeping data integrity of filtered and unfiltered features.

  • But I do edit the attribute table of my shapefile while it is filtered (I edited my question adding some pictures to show it). – Pescariz Mar 7 '17 at 9:27
  • You edit the layer in QGIS memory, but not the shapefile directly. – AndreJ Mar 7 '17 at 12:10
  • But once I finish editing, I copy the data on Excel (to keep on doing other things) and the values I changed in Qgis appear as I changed them in my spreadsheet. – Pescariz Mar 7 '17 at 13:25
  • That's a copy of the memory too. The shapefile is locked while you have set a filter. – AndreJ Mar 7 '17 at 14:20
  • @AndreJ Are you sure filtering + editing is supported with SQLite? It doesn't work in QGIS3. – arjan Mar 11 '18 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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