Question: I'm working on openlayers and need to change the format of dwg to GeoJSON with ArcGIS.
how can i do this?

Answer: 
Indeed, GDAL has the necessary tools to get this done. ogr2ogr is a program included with GDAL that can transform a [variety of formats](https://gdal.org/ogr_formats.html), including DWG. If you don't already have GDAL installed, here are good tutorials for [windows](https://sandbox.idre.ucla.edu/sandbox/tutorials/installing-gdal-for-windows) and [mac/linux](https://web.archive.org/web/20160701215457/https://www.mapbox.com/tilemill/docs/guides/gdal/). The [following guide](https://danielbrannstrom.wordpress.com/2010/11/01/converting-autocad-dwg-files-to-esri-shapefiles/) 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](https://desktop.arcgis.com/en/arcmap/10.3/tools/conversion-toolbox/cad-to-geodatabase.htm) that you can use.
Even if [GDAL](https://gdal.org/) is a good and working solution for [DXF](https://en.wikipedia.org/wiki/AutoCAD_DXF) file (which are CAD files too)

Since the OOP asks about [DWG](https://en.wikipedia.org/wiki/.dwg) file, I would suggest to use the [LibreDWG](https://github.com/LibreDWG/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](https://github.com/sigolo/geofiles-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.

### Windows Users

For Windows users, you can download the [latest release from GitHub](https://github.com/LibreDWG/libredwg/releases) *(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"`