I'm trying to export a DXF file from QGIS 1.8.0 Lisboa and can not have a 3D file in AutoCAD or Microstation. It results always in 2D file.
How can I export height data from a shapefile in QGIS?
I'm trying to export a DXF file from QGIS 1.8.0 Lisboa and can not have a 3D file in AutoCAD or Microstation. It results always in 2D file.
How can I export height data from a shapefile in QGIS?
If you want to get a 3D DXF from a SHP (SHPfile generated from DTM with Qgis-Processing-Tools-GDAL/OGR Extraction-Contour), you must:
1) have column with Z values into Table attributes of SHP. 2) open "OSGeo4W Shell Commands" if you have Windows OS. 3) write into shell for example:
ogr2ogr -f "dxf" d:\Temp\3Doutput.dxf d:\Temp\contour.shp -zfield ELEV
the syntax is as follows: ogr2ogr -f "DXF" {outFile} {inFile} -zfield {ColumnWithZValue}
If an error appear, ignore it, go to the folder that contain the output file and if you find a file named "3Doutput" without extension (in this example), rename it as "3Doutput.dxf", then you will can open it with AutoCAD or other software.
You can't do it from within QGIS itself but you can do it this way:
http://nathanw.net/2011/05/05/3d-dxf-using-ogr/
ogr2ogr -f "DXF" {outFile} {inFile} -zfield {ColumnWithZValue}
In QGIS 3.2.3, it's possible, without using GDAL.
When generating the contours, just check the "Produce 3D Vector" in the "Advanced Parameters".
After that, just export the layer with "Save As". The option "Include Z dimension" will be checked already.
We export our files as a xyz text file for export into 12D for one of our contractors, which may also work if you are having problems, I haven't tried it since we don't have autocad or 12D
I'm not sure if this helps, but I used ogr2ogr and converted from shp to shp adding the -zfield argument and was able to reference the shp into microstation as contours with elevations.
ogr2ogr -f "ESRI Shapefile" {outFile.shp} {inFile.shp} -zfield {ColumnWithZValue}
It worked for me. I used QGIS to produce a shp file from a geotiff from https://data.linz.govt.nz
Then opened GDAL and put as per Nathan W above:
ogr2ogr -f "dxf" C:\0GeoOUT\kane4.dxf C:\0GeoIN\contour.shp -zfield ELEV
So I could understand it better on my system I set up input and output folders. I avoided spaces or periods in paths as I had failure (dxf write failure) when they existed.
I did get these errors (but dxf works fine):
ERROR 4: Unable to open C:\0GeoOUT\kane4.dxf to obtain file list.
ERROR 1: DXF layer does not support arbitrary field creation, field 'ID' not created.
ERROR 1: DXF layer does not support arbitrary field creation, field 'ELEV' not created.
In QGIS 2.18.14 the save as
option has a
datasource
creation field where the -zfield {ColumnWithZValue} could be written.
I did not tested yet, but it looks to be the apporach within QGIS.
The box with Include z-dimension
I guess works only with object with that dimension, but not with shape files.