I run the following code to first select specific attributes using a query and then I need to delete them
from osgeo import gdal, ogr
import os
##shapefile = "D:/New.shp"
##driver = ogr.GetDriverByName("ESRI Shapefile")
##dataSource = driver.Open(shapefile, 0)
shapefile = ogr.Open( "D:/New.shp")
layer = shapefile.GetLayer()
layer.SetAttributeFilter("Area < 5000")
for i in layer:
print i.GetField("Area")
layer.DeleteFeature(i)
I get the following error :
layer.DeleteFeature(i) File
"C:\Python27\ArcGIS10.2\lib\site-packages\osgeo\ogr.py", line 1499, in
DeleteFeature
return _ogr.Layer_DeleteFeature(self, *args) TypeError: not an integer
I changed the last line of my code to ogr.Layer_DeleteFeature(i) to which i get the error
ogr.layer_DeleteFeature(i)
AttributeError: 'module' object has no attribute 'layer_DeleteFeature'