GDAL ogr2ogr 使用多处理的替代方案

问题描述 投票:0回答:1

我正在使用 GDAL 的 ogr2ogr 将 AutoCAD DXF 文件转换为 GeoJSON。我需要转换的一些文件最大为 1.4GB。从功能上讲,ogr2ogr 可以很好地完成这项工作,但这些大型 DXF 文件每个都需要几分钟才能转换。

有没有具有多处理或多线程功能的 ogr2ogr 替代方案?我想这会显着加快转换速度。

谢谢

multithreading multiprocessing gdal autocad dxf
1个回答
0
投票

当您对 ogr2ogr 使用 GDAL python 绑定时,您可以使用标准 python 多处理选项。

使用 gdal.VectorTranslate 的基本示例,Python 绑定到 ogr2ogr:

from osgeo import gdal
gdal.UseExceptions()

src_ds = gdal.OpenEx("input.dxf")
options = gdal.VectorTranslateOptions(format="GEOJSON")
ds = gdal.VectorTranslate("output.geojson", src_ds, options=options)
ds = None

一般来说,geojson 也不是一种写入大文件的简单且缓慢的格式,例如GPKG 将是一个更快、更合乎逻辑的选择,但我认为这种选择是有原因的......

© www.soinside.com 2019 - 2024. All rights reserved.