На fiona 1.5.0 (я запутался, почему различные файлы (такие как .dbf и .gdb) не печатают мое предупреждение «Не шейп-файл!» (Это то, что я хочу В ЛЮБОЕ ВРЕМЯ, чтобы файл не был .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!