使用ogr2ogr转换S57海图遇SG3D字段错误及脚本解析可行性咨询
关于S57海图转换及ogrinfo输出解析的问题
问题背景
我尝试用ogr2ogr转换S57海图格式,但一直失败,ogrinfo和ogr2ogr都会报以下错误:
ISO8211: Didn't find field terminator, read one more byte.
ERROR 1: Not enough byte to initialize field `SG3D'.
特殊现象
- 当设置
S57_PROFILE=iw,且当前目录不存在s57objectclasses_iw.csv和s57attributes_iw.csv时,ogrinfo能正常运行; - 不设置该配置,或目录里有上述两个文件时,就会触发错误;
- 无论什么情况,
ogr2ogr始终返回相同错误,找不到解决办法。
可行的临时操作
我可以通过指定图层名(比如Point),用ogrinfo提取内容,命令如下:
ogrinfo --debug ON --config S57_PROFILE iw -ro ENC_ROOT/FI/FI5SAI5A/1/0/FI5SAI5A.000 Point
执行后输出显示ogrinfo已成功应用更新文件:
S57: The following S57 options are being set: S57: SPLIT_MULTIPOINT=ON S57: ADD_SOUNDG_DEPTH=ON GDAL: GDALOpen(ENC_ROOT/FI/FI5SAI5A/1/0/FI5SAI5A.000, this=0x13a813a80) succeeds as S57. ISO8211: Didn't find field terminator, read one more byte. ERROR 1: Not enough byte to initialize field `SG3D'. S57: Applying feature updates from ENC_ROOT/FI/FI5SAI5A/1/1/FI5SAI5A.001. S57: Applying feature updates from ENC_ROOT/FI/FI5SAI5A/1/2/FI5SAI5A.002. S57: Applying feature updates from ENC_ROOT/FI/FI5SAI5A/1/3/FI5SAI5A.003. INFO: Open of `ENC_ROOT/FI/FI5SAI5A/1/0/FI5SAI5A.000' using driver `S57' successful. Layer name: Point Geometry: Point ...
提取到的要素示例如下:
OGRFeature(Point):0 RCID (Integer) = 1 PRIM (Integer) = 1 GRUP (Integer) = 2 OBJL (Integer) = 119 RVER (Integer) = 1 AGEN (Integer) = 160 FIDN (Integer) = 33707 FIDS (Integer) = 529 LNAM (String) = 00A0000083AB0211 POINT (28.0155887 63.0110526)
核心疑问
通过脚本解析ogrinfo的输出来获取要素,是否安全可行?
内容的提问来源于stack exchange,提问作者Okko Kauhanen
相关产品推荐
相关产品推荐

