[GIS] How to use QGIS to convert points with elevations to DXF

autocaddxfqgis

I'm trying to convert points (with their elevations) into a dxf file for use in AutoCAD LT. I've tried "save as" to dxf for the layer, which appears to almost work…the dxf has x and y location information, but the elevations associated with the points are not present.

I also tried the "dxfauth" openware tool, but that did the same as the above. Thanks!

Best Answer

QGIS does not manage Z coordinates importing CSV files.

You can convert the CSV to DXF using ogr2ogr from the command-line shell. This should be already installed since QGIS uses OGR too.

You need to create a .vrt file along your CSV. This is a plain-text file that you can create with any text editor. It is really easy in your case:

<OGRVRTDataSource>
  <OGRVRTLayer name="test">
    <SrcDataSource>dave.csv</SrcDataSource>
    <GeometryType>wkbPoint</GeometryType>
    <LayerSRS>WGS84</LayerSRS>
    <GeometryField encoding="PointFromColumns" x="x" y="y", z="elev"/>
    <Field name="id" type="String"/>
    <Field name="description"/>
  </OGRVRTLayer>
</OGRVRTDataSource>

Save this file in the same directory as the CSV file. If the CSV file is called dave.csv, it is practical to name it dave.vrt. Check on the third line that the SrcDataSource is correct, that is that the filename is the same as your CSV file. The LayerSRS can probably stay like this, as DXF has no concept of spatial reference system.

When the file is ready, from the command line you would issue:

ogr2ogr dave.dxf dave.vrt 

This procedure is not needed for other formats. See this question about the zfield option in ogr2ogr.