Skip to content

← Blog

From a DEM to contour lines in DWG: GeoTIFF, ASCII Grid and Spain’s IGN

· Guides

For a feasibility study, a site layout or a location plan there is not always a survey or a LiDAR flight. Most national mapping agencies publish a digital elevation model (DEM, also called DTM) as a raster grid, and LinceCAD can bring it into the drawing as a surface and draw contour lines from it as ordinary DWG polylines:

If what you have is a LiDAR point cloud in LAS or LAZ, the route is different: contour lines from a LAS/LAZ point cloud.

What you need

Option A: import a DEM file with IMPORTDEM

  1. Download the DEM of your area from the national agency. If it comes zipped, unzip it: IMPORTDEM reads the .asc or .tif file.
  2. Type IMPORTDEM or click Import DEM in the Terrain data panel and choose the file.
  3. In the Import DEM dialog check the source coordinate system: the one stated by the file is proposed (the GeoTIFF EPSG GeoKey, the .prj of the ASCII Grid or, for Spanish CNIG sheets, the zone in the sheet name, such as …_ETRS89_HU30_…).
  4. Choose the clip: All (the whole sheet), Window (two corners) or Boundary (a closed polyline).
  5. Choose the subsampling (“one cell of every N”); with 0 it is chosen automatically for about 30,000 points. Click OK.

The centre of each cell is used and cells without data (NODATA) are skipped. A DWG face mesh holds at most 32,767 vertices: if the subsampling you ask for gives more, it is increased with a warning. That is why it pays to clip to your working area: with the same number of points, the smaller the area, the closer you stay to the resolution of the file.

Where to download a DEM

The manual’s map servers by country guide lists where to download official DEMs, among others: Spain (CNIG download centre: MDT05, MDT25 and MDT200), Portugal (DGT), France (IGN RGE ALTI), Italy (TINITALY), Mexico (INEGI Continuo de Elevaciones Mexicano), Argentina (IGN MDE-Ar), Brazil (INPE Topodata) and, for the whole world, the Copernicus DEM GLO-30 and SRTM. On each portal, check the file format, its coordinate system and the licence before you use it.

Option B: Spain, straight from the IGN with IGNDEM

  1. Set the drawing’s coordinate system with GEOGRAPHICLOCATION, for example 25830 (ETRS89 / UTM zone 30N).
  2. Zoom to the working area.
  3. Type IGNDEM or click IGN DEM in the Terrain data panel.
  4. At Resolution in metres [5/25/200/500/1000/Auto], press Enter for the automatic resolution or choose the grid spacing.

With Auto, the finest grid with which the view stays below about 250,000 cells is used, and it is then subsampled to about 30,000 points: the closer you zoom, the finer the mesh. For the 5 m DEM, zoom in. The area is requested in ETRS89 / UTM 30 (in the Canary Islands, REGCAN95 / UTM 28), clipped to the view and reprojected to the drawing’s system. The answer is kept in the map cache for seven days. With the view outside Spain, the command says so without calling the service.

Either way, the result is the same kind of surface that SURFACE creates: a 3D face mesh that any DWG program reads.

Draw the contour lines

  1. Type CONTOUR or click Contours and select the surface.
  2. In the Contours dialog give the interval between contours.
  3. Give how often a contour is an index contour (0, none).
  4. Choose the smoothing: None (the contours follow the triangles), Polyline or Spline. The surface is smoothed, not each contour, so neighbouring contours never cross.
  5. Give the distance between labels on the index contours (0, no labels) and click OK.

The contours are polylines (or splines) at their elevation: minor ones on layer CN_FINA and index ones on CN_MAESTRA. The labels read left to right and break the contour instead of masking it, so they look the same in any program. To add labels by hand elsewhere, use CONTOURLABEL.

Choose the interval to suit the grid: the contours come from the surface and cannot show more detail than the DEM grid and the subsampling you used.

What else you can do with the DEM

If you have LiDAR: LIDARSURFACE

A LiDAR point cloud (LAS or LAZ) gives denser ground than a gridded DEM. LIDARSURFACE builds the DTM straight from the cloud with only the ground points (class 2 in classified clouds) and, if you give an interval, draws the contours too. To see the whole cloud, see contour lines from a LAS/LAZ point cloud.

Limitations

Frequently asked questions

Which DEM formats can LinceCAD import?

IMPORTDEM reads gridded DEMs in ESRI ASCII Grid (.asc) and GeoTIFF (.tif), including the MDT05, MDT25 and MDT200 sheets of the Spanish CNIG. A DEM in any other format has to be converted first.

Do I need to download files for Spain?

No. IGNDEM requests the DEM of the area shown on screen from the IGN elevation WCS service and creates it as a surface. It only covers Spain.

How many points does an imported DEM have?

A DWG face mesh holds at most 32,767 vertices, so by default the grid is subsampled to about 30,000 points. Clip the DEM to your working area to keep as much of its resolution as possible.

DEM import, Spain’s IGN DEM and contour lines come built in to LinceCAD, with a free 30-day trial and a perpetual licence. Download · See pricing · CAD software for surveyors.