From a DEM to contour lines in DWG: GeoTIFF, ASCII Grid and Spain’s IGN
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:
IMPORTDEMimports a DEM file in ESRI ASCII Grid or GeoTIFF, from any country.IGNDEMdownloads the DEM of the area on screen from the WCS service of Spain’s Instituto Geográfico Nacional (IGN), without downloading or unzipping sheets.
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
- The drawing’s coordinate system, set with
GEOGRAPHICLOCATION. If the DEM is in another system, the elevations are reprojected to the drawing’s, with a warning when the datum changes. - The DEM file for
IMPORTDEM, or an internet connection forIGNDEM. - The licence of the data. Most official DEMs can be reused citing the source; check each one. Spain’s IGN DEM
is CC BY 4.0 (“Instituto Geográfico Nacional”), and
IGNDEMlabels the source in the lower-left corner of the view.
Option A: import a DEM file with IMPORTDEM
- Download the DEM of your area from the national agency. If it comes zipped, unzip it:
IMPORTDEMreads the.ascor.tiffile. - Type
IMPORTDEMor click Import DEM in the Terrain data panel and choose the file. - In the Import DEM dialog check the source coordinate system: the one stated by the file is proposed (the
GeoTIFF EPSG GeoKey, the
.prjof the ASCII Grid or, for Spanish CNIG sheets, the zone in the sheet name, such as…_ETRS89_HU30_…). - Choose the clip:
All(the whole sheet),Window(two corners) orBoundary(a closed polyline). - 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
- Set the drawing’s coordinate system with
GEOGRAPHICLOCATION, for example25830(ETRS89 / UTM zone 30N). - Zoom to the working area.
- Type
IGNDEMor click IGN DEM in the Terrain data panel. - 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
- Type
CONTOURor click Contours and select the surface. - In the Contours dialog give the interval between contours.
- Give how often a contour is an index contour (0, none).
- Choose the smoothing: None (the contours follow the triangles), Polyline or Spline. The surface is smoothed, not each contour, so neighbouring contours never cross.
- 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
SPOTELEVATIONgives the ground elevation at any point and, with the Label option, draws it.PROFILEVIEWdraws the longitudinal profile along an alignment.SURFACEANALYSIScolours the surface by slope, elevation bands or aspect.SURFACEVOLUMEcomputes earthworks against a design: cut and fill volumes between two surfaces.LANDXMLOUTexports the DTM to LandXML.
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
- The accuracy is that of the DEM. The contours have the detail of the grid and of the subsampling; they do not replace a survey for designing works.
- About 30,000 points per import. Because of the vertex limit of a DWG mesh, a large area is subsampled more. Clip to what you need.
- IGNDEM needs a connection and only answers inside Spain.
- IMPORTDEM only reads ASCII Grid and GeoTIFF. A DEM in another format has to be converted first.
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.