I'm working on openlayers and need to change the format of dwg to GeoJSON with ArcGIS. how can i do this?
View or convert with DWG TrueView View DWG files or convert them to work with older versions of AutoCAD software. Add Design Review to mark up 2D and 3D files without the original design software. For greater flexibility consider Autodesk Viewer or AutoCAD web app.
SOLIDWORKS includes an Import Wizard to allow DWG/DXF files to be imported directly into the sketcher – from there it can easily be turned into a 3D model.
Indeed, GDAL has the necessary tools to get this done. ogr2ogr is a program included with GDAL that can transform a 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 recommends converting to a DXF first, since the library for converting from DXF is included by default with GDAL. You will need to install some additional dependencies to convert directly from DWG. If you convert to DXF first, you can then use command line to convert to GeoJson:
ogr2ogr -f GeoJSON ./mynewfile.geojson ./mycadfile.dxf
If you are using ArcGIS Desktop there is a CAD to Geodatabase tool that you can use.
Even if GDAL is a good and working solution for DXF file (which are CAD files too)
Since the OOP asks about DWG file, I would suggest to use the LibreDWG library that support conversion from DWG to GeoJSON files and has very good performance.
You can use it like so :
dwgread <input_file_path> -O GeoJSON -o <output_file_path>
There are also many other commands provided by this fantastic library. I am also currently work on an open source project Geofiles-convertor Rest API which is a REST API that aims to make popular geofiles format conversion easier. It is also based on both GDAL and LibreDWG and there is a Docker image ready to run.
For Windows users, you can download the latest release from GitHub (win32.zip or win64.zip), which has dwgread.exe
file.
You can then open a terminal in the downloaded folder location and run the command dwgread.exe "D:\path\to\file.dwg" -O GeoJSON -o "D:\path\to\output.json"
GDAL can be used to do this, and I want to say ogr2ogr too, but not 100%.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With