Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add edit geometries with query filter #27356

Closed
qgib opened this issue Aug 2, 2018 · 9 comments
Closed

Add edit geometries with query filter #27356

qgib opened this issue Aug 2, 2018 · 9 comments
Labels
Data Provider Related to specific vector, raster or mesh data providers Feature Request

Comments

@qgib
Copy link
Contributor

qgib commented Aug 2, 2018

Author Name: Jérôme Seigneuret (Jérôme Seigneuret)
Original Redmine Issue: 19529

Redmine category:data_provider/ogr


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 issue(s): #13011 (duplicates)
Redmine related issue(s): 2951


@qgib
Copy link
Contributor Author

qgib commented Aug 2, 2018

Author Name: Giovanni Manghi (@gioman)


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.


  • category_id was changed from Editing to Vectors
  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented Aug 2, 2018

Author Name: Jérôme Seigneuret (Jérôme Seigneuret)


Ok, I send a question to GDAL-Dev mailling list

@qgib
Copy link
Contributor Author

qgib commented Aug 2, 2018

Author Name: Even Rouault (@rouault)


@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))


  • status_id was changed from Feedback to Open
  • category_id was changed from Vectors to Data Provider/OGR

@qgib
Copy link
Contributor Author

qgib commented Aug 2, 2018

Author Name: Even Rouault (@rouault)


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.

@qgib
Copy link
Contributor Author

qgib commented Aug 2, 2018

Author Name: Jürgen Fischer (@jef-n)


@qgib
Copy link
Contributor Author

qgib commented Aug 2, 2018

Author Name: Jürgen Fischer (@jef-n)


@qgib
Copy link
Contributor Author

qgib commented Aug 2, 2018

Author Name: Jürgen Fischer (@jef-n)


@qgib
Copy link
Contributor Author

qgib commented Aug 3, 2018

Author Name: Giovanni Manghi (@gioman)


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

@alexbruy
Copy link
Contributor

alexbruy commented Dec 3, 2023

Duplicates #21350

@alexbruy alexbruy closed this as completed Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data Provider Related to specific vector, raster or mesh data providers Feature Request
Projects
None yet
Development

No branches or pull requests

2 participants