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?

  • Do you have one of the required libraries installed? either 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 gis.stackexchange.com/questions/42158/… – AndreJ Jun 13 '17 at 5:53
  • dang good call @AndreJ looks like im out of luck – ziggy Jun 13 '17 at 15:40
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.