3

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?

7

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.

4

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}
  • Didn't work, it says it's not a recognized command. Any other tip? Thank you for your prompt response – Jorge Marques Apr 1 '13 at 23:27
  • You will need to run it using the OSGeo4W shell (if your on windows that is) – Nathan W Apr 1 '13 at 23:32
  • C:\>ogr2ogr -f "DXF" E:\tsteQgis\processameto\mapset\CN3D_vf E:\tsteQgis\process ameto\mapset\CN.shp -zfield CONTOUR ERROR 1: DXF layer does not support arbitrary field creation, field 'ID' not cre ated. ERROR 1: DXF layer does not support arbitrary field creation, field 'ELEV' not c reated. C:\>ogr2ogr -f "DXF" E:\tsteQgis\processameto\mapset\CN3D_vf1 E:\tsteQgis\proces sameto\mapset\CN.shp -zfield ELEV ERROR 1: DXF layer does not support arbitrary field creation, field 'ID' not cre ated. ERROR 1: DXF layer does not support arbitrary field creation, field 'ELEV' not c reated. – Jorge Marques Apr 2 '13 at 9:41
  • That is the error that i got using the tip you gave me! I'm running out of solutions to overcome this problem. You know any other solution? Thank you so much! – Jorge Marques Apr 2 '13 at 9:43
  • Does it still make the dxf file though. DXFs don't have fields so that is a warning your get not really a error. – Nathan W Apr 2 '13 at 9:49
0

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

0

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}

0

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.
0

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.

menu save as

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.