Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am new to Quantum and I am digitizing polygon layers using the editing features. I would like to apply simple queries ('date > 2012/08/01'), however while the query is active I cannot edit the layer. Is this possible?

share|improve this question

2 Answers 2

No, it's not possible to enable editing on filtered layers.

You can try using a rule-based renderer instead of a filter. Set the rule so that only your features of interest are displayed. Then enable editing.

share|improve this answer
    
Thank you for help, it did exactly what I needed it to. Rule-based rendering is a pretty useful feature. –  Brandon G Aug 30 '12 at 17:20
    
Glad I could help. Please accept the answer by clicking the tick mark under the vote counter to the left if your question is answered. –  underdark Aug 30 '12 at 17:55

Currently you can't edit a Shapefile layer while it is filtered. However, if you add a database layer, you can edit the layer while a filter is applied. This works with SpatiaLite and PostGIS, and I assume that it also works with Oracle and MSSQL connections. If this is the main functionality you need, though, SpatiaLite is easiest to work with as it is a file-based database and well supported in QGIS. In many ways it's as easy to work with as a Shapefile (see What are advantages of using spatialite over shapefile?).

Step 1

If you have an existing layer you want to have editable while filtering, you can save the layer as a SpatiaLite database by right-clicking on the layer and choosing Save As.... In the dialog that opens, set the Format as SpatiaLite, and choose a filename and location for the file.

Save as Spatialite

Note that it's best not to select Add saved file to map as it would add it as a regular file layer rather than as a database connection, and you wouldn't be able to edit it while filtered. For the same reason, dragging and dropping a SpatiaLite file into your QGIS workspace will add the file to your project, but it won't be editable while a filter is applied.

Step 2

In the menu, click Layer > Add SpatiaLite Layer. Click the New button, and then browse to your SpatiaLite file (the extension will be .sqlite). Then click the Connect button to create a link to the database. Select the table name, then click the Add button to add it as a layer to QGIS.

Add SpatiaLite tables

Step 3

You can then set a filter on the layer by right-clicking, and selecting Filter... from the context menu. Apply your filter using the Query Builder.

Set filter

Step 4

With the filter active, you can now edit the layer using the canvas or the attribute table.

Apply edits

Note that you will not be able to change the filter while the layer is in edit mode, but you can turn off edit mode, change the filter, and then turn editing on again. You can also add additional layers to your project and keep them all in the same SpatiaLite database as separate tables.

These instructions should work for QGIS 2.0 and up, but may not work for earlier versions.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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