在 fiona 1.5.0 上(我很困惑为什么各种文件(例如 .dbf 和 .gdb)没有打印我的“不是 Shapefile!”(这是我在任何时候想要的文件不是 .shp)警告在退出之前。
import fiona
import sys
def process_file(self, in_file, repair_file):
with fiona.open(in_file, 'r', encoding='utf-8') as input:
# check that the file type is a shapefile
if input.driver == 'ESRI Shapefile':
print "in_file is a Shapefile!"
else:
print "NOT a Shapefile!"
exit()
with fiona.open(repair_file, 'r') as repair:
# check that the file type is a shapefile
if repair.driver == 'ESRI Shapefile':
print "Verified that repair_file is a Shapefile!"
else:
print "NOT a Shapefile!"
exit()
对于 gdb,我收到 fiona 不支持驱动程序的错误(因为 ogr 确实让我感到惊讶)-并且没有打印语句:
>> fiona.errors.DriverError: unsupported driver: u'OpenFileGDB'
对于.dbf,我实际上得到了这个:
>> Verified that in_file is a Shapefile!
>> Verified that repair_file is a Shapefile!