2

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?

ziggy
  • 4,515
  • 3
  • 37
  • 83
  • Do you have one of the required libraries installed? either https://github.com/sandyre/libopencad or Open Design Alliance Teiga library – firefly-orange Jun 12 '17 at 15:09
  • i have windows and i need to install a library for this conversion using ogr2ogr? – ziggy Jun 12 '17 at 15:26
  • 2
    Is DWG listed in ogrinfo --formats|sort? If not, you are out of luck. See https://gis.stackexchange.com/questions/42158/where-can-i-find-a-gdal-distribution-with-dwg-support – AndreJ Jun 13 '17 at 05:53
  • dang good call @AndreJ looks like im out of luck – ziggy Jun 13 '17 at 15:40

1 Answers1

3

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.

AndreJ
  • 76,698
  • 5
  • 86
  • 162