Feature request #19529
Add edit geometries with query filter
Status: | Open | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Data Provider/OGR | ||
Pull Request or Patch supplied: | No | Resolution: | |
Easy fix?: | No | Copied to github as #: | 27356 |
Description
Hi,
I use global data shapefile. I use filter on my layer data source and I can't edit geometries because there is a query filter...
Can you modifiy this behaviour.
Related issues
History
#1 Updated by Giovanni Manghi over 6 years ago
- Category changed from Editing to Vectors
- Status changed from Open to Feedback
No it can't be changed, because ogr (used to read shapefiles) does not allow it.
You must use a less obsolete format, like geopackage or spatialite.
#2 Updated by Jérôme Seigneuret over 6 years ago
Ok, I send a question to GDAL-Dev mailling list
#3 Updated by Even Rouault over 6 years ago
- Status changed from Feedback to Open
- Category changed from Vectors to Data Provider/OGR
@giovanni This is not actually true. This is more a limitation on QGIS side
Demo that the shapefile driver can support this:
even@even-i700:~/gdal/git/gdal/gdal$ ogrinfo poly.shp -al -where "EAS_ID = 165"
INFO: Open of `poly.shp'
using driver `ESRI Shapefile' successful.
Layer name: poly
Geometry: Polygon
Feature Count: 1
Extent: (478315.531250, 4762880.500000) - (481645.312500, 4765610.500000)
Layer SRS WKT:
(unknown)
AREA: Real (12.3)
EAS_ID: Integer64 (11.0)
PRFEDEA: String (16.0)
OGRFeature(poly):8
AREA (Real) = 596610.313
EAS_ID (Integer64) = 165
PRFEDEA (String) = 35043408
POLYGON ((479750.6875 4764702.0,479968.46875 4764788.0,479985.0625 4764732.0,480011.0 4764674.5,480093.75 4764703.0,480177.15625 4764742.0,480258.03125 4764767.0,480343.71875 4764532.5,480343.5625 4764477.0,480316 4764395,480289.125 4764348.5,480234.3125 4764304.0,480157.125 4764266.5,480192.3125 4764183.0,480120.21875 4764188.5,479550.0625 4763919.5,479492.6875 4763850.0,479487.75 4763864.5,479442.75 4763990.0,479436 4764023,479398.9375 4764100.0,479349.625 4764230.0,479305.875 4764361.0,479239.8125 4764505.0,479504.90625 4764609.5,479658.59375 4764670.0,479750.6875 4764702.0))
even@even-i700:~/gdal/git/gdal/gdal$ python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
from osgeo import ogr
ds = ogr.Open('poly.shp', update = 1)
lyr = ds.GetLayer(0)
lyr.SetAttributeFilter('EAS_ID = 165')
0
f = lyr.GetNextFeature()
f['AREA'] = -f['AREA']
lyr.SetFeature(f)
0
even@even-i700:~/gdal/git/gdal/gdal$ ogrinfo poly.shp -al -where "EAS_ID = 165"
INFO: Open of `poly.shp'
using driver `ESRI Shapefile' successful.
Layer name: poly
Metadata:
DBF_DATE_LAST_UPDATE=2018-08-02
Geometry: Polygon
Feature Count: 1
Extent: (478315.531250, 4762880.500000) - (481645.312500, 4765610.500000)
Layer SRS WKT:
(unknown)
AREA: Real (12.3)
EAS_ID: Integer64 (11.0)
PRFEDEA: String (16.0)
OGRFeature(poly):8
AREA (Real) = -596610.313
EAS_ID (Integer64) = 165
PRFEDEA (String) = 35043408
POLYGON ((479750.6875 4764702.0,479968.46875 4764788.0,479985.0625 4764732.0,480011.0 4764674.5,480093.75 4764703.0,480177.15625 4764742.0,480258.03125 4764767.0,480343.71875 4764532.5,480343.5625 4764477.0,480316 4764395,480289.125 4764348.5,480234.3125 4764304.0,480157.125 4764266.5,480192.3125 4764183.0,480120.21875 4764188.5,479550.0625 4763919.5,479492.6875 4763850.0,479487.75 4763864.5,479442.75 4763990.0,479436 4764023,479398.9375 4764100.0,479349.625 4764230.0,479305.875 4764361.0,479239.8125 4764505.0,479504.90625 4764609.5,479658.59375 4764670.0,479750.6875 4764702.0))
#4 Updated by Even Rouault over 6 years ago
Hum actually the OGR provider doesn't use SetAttributeFilter() but ExecuteSQL(), and the later can make it difficult to find the original FID, so this might be non trivial to implement.
#5 Updated by Jürgen Fischer over 6 years ago
- Duplicates Feature request #3052: Editing subsets doesn't work for shapefiles added
#6 Updated by Jürgen Fischer over 6 years ago
- Duplicates Bug report #2951: Layers become non-editable added
#7 Updated by Jürgen Fischer over 6 years ago
- Duplicates deleted (Feature request #3052: Editing subsets doesn't work for shapefiles)
#8 Updated by Giovanni Manghi over 6 years ago
Even Rouault wrote:
@giovanni This is not actually true. This is more a limitation on QGIS side
Sorry, I always assumed it was an ogr/shapefile limitation, see this very old answer from Jurgen: https://issues.qgis.org/issues/2951#note-3