Diesen Artikel gibt es noch nicht auf Deutsch — Sie lesen ihn auf Englisch.

Contour Lines in DXF All in One Plane: Where the Height Goes

2026-11-245 min read
DXFDWG

This is a walk through one common pain that designers and GIS people keep running into on forums. There are no names here, only what goes wrong, why, and what we changed on the site. If you received contour lines in a DXF and your CAD program shows every one of them at zero, this article is about you.

What hurts

Someone builds contour lines from a terrain model and saves them to DXF to hand over to a designer. The lines are all there and the shape of the ground reads well on screen. Then the drawing is turned into a 3D view, and the whole set of contours lies in one flat plane. The 120 metre line and the 160 metre line sit at the same height. You cannot build a surface from them, and you cannot cut a section through them.

The worst part is that there is no error. The file saves quietly, the program says nothing, and the recipient only finds out when the drawing is already on their screen. The usual advice on forums is to rename the height field to "Elevation" so that the export recognises it, or to push the layer through a separate processing tool. That works sometimes, and it depends on which field name a particular program happens to expect.

One detail matters here: the height values do exist. This is not the case where contours were drawn without any data. The height is stored in the layer's attribute table, and it simply never reaches the drawing.

Why it happens

The DXF format stores geometry, a layer name and a colour. It does not carry the attribute table from a GIS on its own. If the export does not know that the "height" field belongs in a coordinate, the value is lost on the way. Our own export used to behave the same way at first: the standard drawing writer in QGIS does not put the contour height attribute into the file at all, neither as extended data nor as text.

What we fixed on the site

We do not rely on the field name. After the drawing has been written, a separate step finds every contour polyline and writes its height in two places:

  • in the elevation field of the polyline (group code 38 on a LWPOLYLINE). This is the height that a 3D view, surface building and sections actually use;
  • in XDATA, as an ELEVATION key followed by the number. This one is for scripts in LISP, ObjectARX or ezdxf, and it does not clutter the view.

On top of that, contour labels go as text on their own layer, and spot heights get a separate layer as well. There is no need to give the field a magic name: the height arrives by itself.

What we do not promise: the vertices of a contour do not carry their own Z. A contour line is flat by definition, so the whole line lies at one height. The elevation field says exactly that: one height for the whole polyline. Rewriting every line as a 3D polyline to get the same result would make the file noticeably heavier and break compatibility with older programs, which read LWPOLYLINE vertices as plain x and y anyway.

Diagram of how a flat drawing looks to the recipient: in plan the contours are all there, in a side view they all sit at zero; not a screenshot

How we measured it

In September 2026 we ordered a DXF drawing on the site for a hillside town by the sea, with contour lines, contour labels and spot heights switched on, and took the file apart with a script. It holds 233 contour polylines on the layers for thin and bold contours. The elevation field is filled in on all 233 of them, with 25 distinct heights from 5 to 125 metres at a 5 metre interval. Every one of the 200 lines we checked carries XDATA with the ELEVATION key and its value. There are 47 contour labels, plus a separate layer of spot heights.

Diagram from our test: in the same drawing 233 of 233 contours sit at their own heights, 25 levels from 5 to 125 m; not a screenshot

How to check your own file in a minute

  1. Open the drawing and select any contour line.
  2. In the properties panel look at the "Elevation" field. A 120 metre contour should show 120 there, not 0.
  3. Turn the view into 3D. The contours should step apart by height like a staircase instead of merging into one sheet.

If every line shows zero, the height was lost during export. In that case ordering the drawing again is usually faster than lifting hundreds of lines by hand.

Questions people ask

Does the same apply to DWG? Yes. The DWG file is built from the same drawing, so the contour heights survive.

Where do the heights come from? From an open terrain model with a grid of about 30 metres. That is not enough for survey work or for a design that depends on exact levels: treat it as a base map, not as a topographic survey.

Can I read the height from a script? Yes. Read the elevation property of each LWPOLYLINE, or the ELEVATION value from its XDATA; both hold the same number.

More about contour drawings for surveyors is in the article contour lines in DXF for surveyors. About huge symbols in nanoCAD and degrees instead of metres, see DWG in nanoCAD: huge symbols.

Make the same map Order a custom map

← All articles