fiona 1.5.0 で (なぜさまざまなファイル (.dbf や .gdb など) が私の "Not a 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の場合、フィオナがドライバーをサポートしていないというエラーが表示されます(ogrが私を驚かせたため)-およびprintステートメントはありません:
>> fiona.errors.DriverError: unsupported driver: u'OpenFileGDB'
.dbf の場合、実際にこれを取得します。
>> Verified that in_file is a Shapefile!
>> Verified that repair_file is a Shapefile!