Code below is working, but after opening - there are No features in shp file. What can be a problem?
import osgeo, os from osgeo import ogr, gdal shpFile = r'C:\Users\ReBurns.shp' driver = ogr.GetDriverByName('ESRI Shapefile') ptsDS = driver.Open(shpFile) ptsLayer = ptsDS.GetLayer() #Passing criteria to select polygons: myQuery = 'Area_ha > 39000.00' ptsLayer.SetAttributeFilter(myQuery) print ptsLayer ptsLayer.GetFeatureCount() #Save selected features to disk outds = driver.CreateDataSource(r'C:\Users\ReBurns111.shp') outlyr = outds.CopyLayer(ptsLayer,'ReBurns111.shp')
Traceback (most recent call last): File "<ipython-input-167-1e169b0c7c9c>", line 44, in <module> outlyr = outds.CopyLayer(ptsLayer,'ReBurns111.shp') AttributeError: 'NoneType' object has no attribute 'CopyLayer'
No selected files, but how to pass selected by criterias?