我想使用GDAL的SetAttributeFilter()过滤我shapefile的图层中的功能,但过滤器似乎没有效果。Python的GDAL,SetAttributeFilter不工作
我目前的数据是来自美国人口普查局的shapefile,但我已经尝试过使用其他shapefile并得到类似的结果。
例如
from osgeo import ogr
shapefile_path = '../input/processed/shapefile/'
shapefile_ds = ogr.Open(shapefile_path)
cbsa = shapefile_ds.GetLayer('cb_2016_us_cbsa_500k')
print(cbsa.GetFeatureCount())
cbsa.SetAttributeFilter('NAME = "Chicago-Naperville-Elgin, IL-IN-WI"')
feat = cbsa.GetNextFeature()
print(feat.GetField('NAME'))
print(cbsa.GetFeatureCount())
息率
945
Platteville, WI
945
我使用Python 3.6和2.2.1 GDAL
你是完全正确的,我得到的5返回值和交换的曲otes工作。非常感谢! – Chris