I'm following the book 'Geoprocessing with python', and I'm just trying to filter countries by their continent with this code:
from osgeo import ogr import ospybook as pb fn = os.path.join(data_dir, 'ne_10m_admin_0_countries') ds = ogr.Open(fn) lyr = ds.GetLayer('ne_10m_admin_0_countries') lyr.SetAttributeFilter('CONTINENT = "Asia"')
I can open and read the file with all the attributes, but when I try to use the SetAttributeFilter with Asia for example , I always get the answer:
ERROR 1: "Asia" not recognised as an available field.
I've tried this with diffrent shapefiles and always get the same error.