testFiona.py 594 B

123456789101112131415161718
  1. import fiona
  2. shpPath = r'D:\Users\Desktop\新建文件夹\20250407410320\导出部标错误\shp\bb_error.shp'
  3. # with fiona.open(shpPath, encoding='utf-8') as shp:
  4. # print(shp.encoding)
  5. # print('shp的字段信息')
  6. # fields = shp.schema['properties']
  7. #
  8. # # 遍历字段信息
  9. # for k, v in fields.items():
  10. # print(f'{k}->{v}')
  11. # # 遍历要素信息
  12. # for x in shp:
  13. # print(x)
  14. with fiona.Collection(shpPath) as shp:
  15. for feature in shp:
  16. print(feature['geometry']) #读取图形
  17. print(feature['properties']['XZQMC']) #读取属性