如何将我的 CAD(DWG) 文件转换为 GeoJSON?

How can i convert my CAD(DWG) file to GeoJSON?

我正在使用 openlayers,需要使用 ArcGIS 将 dwg 的格式更改为 GeoJSON。 我该怎么做?

GDAL can be used to do this, and I want to say ogr2ogr 也是,但不是 100%。

的确,GDAL 拥有完成此任务的必要工具。 ogr2ogr 是 GDAL 中包含的一个程序,可以转换 variety of formats, including DWG. If you don't already have GDAL installed, here are good tutorials for windows and mac/linux. The following guide 建议首先转换为 DXF,因为默认情况下 GDAL 包含用于从 DXF 转换的库。您将需要安装一些额外的依赖项才能直接从 DWG 进行转换。如果先转换为 DXF,则可以使用命令行转换为 GeoJson:

ogr2ogr -f GeoJSON ./mynewfile.geojson ./mycadfile.dxf

如果您使用的是 ArcGIS Desktop,则可以使用 CAD to Geodatabase tool

即使 GDAL is a good and working solution for DXF 文件(也是 CAD 文件)

由于 OOP 询问 DWG file, I would suggest to use the LibreDWG 支持从 DWG 文件转换为 GeoJSON 文件并具有非常好的性能的库。

你可以这样使用它:

dwgread <input_file_path> -O GeoJSON -o <output_file_path>

这个出色的库还提供了许多其他命令。 我目前还在从事一个开源项目 Geofiles-convertor Rest API,这是一个 REST API,旨在简化流行的地理文件格式转换。 它也基于 GDAL 和 LibreDWG,并且有一个 Docker 图像准备 运行。

可能您还需要将您的坐标从 AutoCAD(如果以米为单位)匹配到 geojson(GPS 坐标)。

  • 首先:lambert 93 到您瞄准的世界区域的 select 部分。
  • 第二:3 点重点关注仿射变换以适应 AutoCAD 几何图形(旋转、平移、缩放)。

你可以看看这个文档: https://github.com/open-indoor/openindoor6/blob/main/AUTOCAD.md

此外,DWG 到 DXF 的解决方案(无人值守的 ODAFileConverter Docker): https://github.com/open-indoor/dwg-to-dxf