Is it possible to create 3D dxf with OGR?

Easier then I thought (thanks to BenjaminGolder for the tip):

ogr2ogr -f "DXF" Contours.dxf Contours.TAB -zfield Height

Contours.TAB is the input MapInfo tab file.


For the sake of completeness.

I believe this should be a comment on Regan response. But since I don't have enough reputation I'll leave it as a response.

The DXF writer supports 2.5D layers, and given a line input, should output a 3D linestring on dxf.

In the case of input POLYGONS you have to be more careful, since the driver defaults to generate a dxf HATCH with a Polyline. And by format specification, that line does not support Z coordinates, only X,Y.

If you input polygons, ogr can export dxf with 3D linestrings representing those polygons. For that you need to set up the config option DXF_WRITE_HATCH to NO.

//Bash
export DXF_WRITE_HATCH=NO
ogr2ogr -f "DXF" Contours.dxf Contours.TAB

//Windows
set NEWVAR=SOMETHING
ogr2ogr -f "DXF" Contours.dxf Contours.TAB

As far as I am aware this is not documented nor explained anywhere, it was added on revision 24991