[GIS] ogr2ogr dwg CAD file to postgres

cadogr2ogrpostgresql

I am attempting to load a CAD .dwg file into a postgreSQL database using ogr2ogr.

this is the command

ogr2ogr -f PostgreSQL "PG:host=localhost user=postgres password=*** dbname=jaffe" C:\Users\blah\Desktop\SAMCO.dwg -s_srs EPSG:4326 -lco GEOMETRY_NAME=geom

get this error

FAILURE:
Unable to open datasource `C:\Users\blah\Desktop\SAMCO.dwg' with the following drivers.

what am I doing wrong?

EDIT

I realized the CAD file has no SRID number associated with it, could that cause the problem?

Best Answer

According to Where can I find a GDAL distribution with DWG support? you need to buy a license for the library that can support DWG in GDAL-based software.

For that reason, it is not included by default in GDAL builds.

There has been some work to overcome this last year: https://trac.osgeo.org/gdal/wiki/DWG_driver, but it is not yet in OSGEO4W or Gisinternals builds.

At the moment, the best workaround is to save the file as DXF inside Autocad.

Related Question