[gdal-dev] Trouble with removing features in .gdb

Maggie Wooten mwoo391 at gmail.com
Tue Mar 9 12:21:22 PST 2021


I keep coming back to this issue, where I cannot delete features from a
.gdb in Python. I don't get any errors, it just doesn't do anything.  I
have searched the internet for solutions (which is how I got what I have
now) but none of the suggestions are working. Any other suggestions I could
try? It is a rather larger .gdb and I would prefer to not start from
scratch or have to copy it to a new .gdb.

Here is my code:

driver = ogr.GetDriverByName('FileGDB')
fc = driver.Open(inFC, 1)
fcLayer = fc.GetLayer()

for f in featureList:
    fcLayer.DeleteFeature(f)
    fc.ExecuteSQL('REPACK ' + fcLayer.GetName())
    fc.ExecuteSQL('RECOMPUTE EXTENT ON ' + fcLayer.GetName())

Where featureList is a list of integers that correspond to the features I
want to delete and inFC is the path a the .gdb I want to delete them from.

I am using GDAL 2.2.2.

My apologies if I have not submitted this email correctly, or am missing
information. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210309/40ff809d/attachment.html>


More information about the gdal-dev mailing list