GIS to CAD using ogr2ogr – Part 1 – Shp to DXF with Contour Data

GIS to CAD using ogr2ogr – Part 2 – GML to DXF with OS MasterMap
GIS to CAD using ogr2ogr – Part 3 – Point Annotation to Text in CAD

The power of GDAL, and specifically ogr2ogr is pretty impressive. This conversion is from shp to DXF, which is a somewhat universal CAD format so further conversion should be possible.

This post will cover contour export while maintaining 3D elevation, in addition to contour values as layers in CAD. The data used is OS terrain 50.

OS Terrain 50:

https://www.ordnancesurvey.co.uk/opendatadownload/products.html

In QGIS:

Screenshot[1]

Contours in 3D:

With the -zfield creating the 3d elevation.

Great result:

Screenshot[3]

The alternative is to just store the z-value as layers.

Layers work great:

Screenshot[2]

With the ogr2ogr DXF driver, if you have an input column called “Layer” then it will be used to group features as a layer in DXF. We use a SQL query to achive this. Prop_Value is the height field in my input data.

And putting them all together:

Result not as expected, flat output:

Screenshot[4]

Adding our SQL select statement removes our zfield attribute as such ogr2ogr cannot access it. Lets resolve this:

Excellent:

Screenshot[5]

Layers and height.

2 thoughts on “GIS to CAD using ogr2ogr – Part 1 – Shp to DXF with Contour Data

  1. Pingback: GIS to CAD using ogr2ogr – Part 1 – Shp to DXF with Contour Data | GeoNe.ws

  2. Pingback: GIS to CAD using ogr2ogr – Part 2 – GML to DXF with OS MasterMap | GIS for Thought

Leave a Reply

Your email address will not be published.