2

Having tried Project -> Export DXF as well as right clicking my vector layer and using the save by dxf feature I have found that the contours do not show in AutoCAD to be elevated from 0

I have checked the attributes of the contours vector layer and find and attribute set containing ID,ELEV and going further I have tried the command:

ogr2ogr -f "DXF" contours-out.dxf contours.shp -zfield ELEV

which I have run successfully although I found that I had to download some version of gdal tools and add the path to my system to the various gdal subfolders I am finding that still the contours do not elevate from 0 and all are still drawn to a 0 elevation in AutoCAD.

  • I also received at some point an error in my console about the creation of an additional attribute ID which is not supported reported by the ogr2ogr command.

Is there a way to export contours to DXF with elevations?

Before I posted this question I read: Exporting QGIS contour attributes in DXF file? and a few others like it.

  • Have you confirmed that the "ELEV" field is correct by looking at the attribute table? – Scro Jan 6 '16 at 9:44
3

If your original data set is in 2D then you have to add -dim 3. Try this command:

ogr2ogr -dim 3 -zfield ELEV -f DXF contours-out.dxf contours.shp

The warning about attribute creation is no problem, DXF files cannot store attributes in a GIS way.

You can use ogrinfo to check the dimension of the output entities, e.g:

ogrinfo -al contours-out.dxf

Be careful using LibreCAD to view DXF, it is restricted to 2D!

  • It didn't work for me. ogrinfo is listing all zero elevations for the AcDbPolylines. I used the defaulted attribute name ELEV when I created contrours in qGIS. The attribute box was checked during that process. My OS is Windows 10. – Eae Jan 6 '16 at 7:59
  • 1
    I tried it on linux successfully. Are you using gdal 1.8 or newer? -zfield available from gdal 1.8 (gdalinfo --version from the command line). – Zoltan Jan 6 '16 at 8:10
  • I had to use this build on OS X to get that working... It uses GDAL 1.1 they say on the webpage. – Eae Jan 6 '16 at 9:48

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.