Contours to Grid Data – Managing Irish Terrain in TrueViewVisuals

Within our TrueViewVisuals solutions we need a terrain data model of the real-world to base our AR visual impact solutions on.  We either manage terrain data as “National” coverage (e.g. in the UK, Canada and in France) or as custom terrain on a per-project data for licencing or resolution requirements.

This technical blog explains how we manage Irish terrain data and process on a per-project basis as there is no Open Data solution or gridded data readily available nationwide.

Ireland – The Data

OSI (the Ordnance Survey Ireland) supply terrain data as tiles of contours. Our client receives these as DXF files compatible with CAD systems and readable by most software systems.

QGIS – The Processing Solution

Free and Open Source Software (FOSS) have been adopted by TrueViewVisuals since our inception. Although we use a variety of tools, QGIS is a mature and functional solution that manages coordinate systems, wide ranging data support, vector analysis and image processing.  It also includes customisation and plug-ins to expand capabilities through organisational and community organisational support.

To download and install QGIS, use the “with GRASS” option from the OSGeo4W Network installer. If you can pass this section then you are technically competent to continue to the instructions below.

DXF Contours Imported

The first stage of the process is to set up the project and import the data:

  1. Create a New Project (Menu: Project/New)
  2. Add the Contour DXF Files (Processing Toolbox: v.in.dxf)
    Multi-select DXF files (or repeat for each file)
    filter layers, e.g. “Contour_10,Contour_20,Contour_50” for our data
    click ‘Run’
  3. Set the coordinate system of the data files.
    For this example we need to assign EPSG 29903to each file (highlight the layers in the legend and right-click  Set SRS/Set Layer SRS.
  4. Merge the files (Processing toolbox:merge)
    In order to simplify layer selection, we will work with one layer.
    * At this stage we will also set the correct coordinate system for the data by merging the source files to one SHP file in CRS 2157.
  5. Set the coordinate system of the project (Menu: Project/Properties…)
    TrueViewVisuals uses ITM for Irish data imports so select EPSG 2157.
  6. Create a GRASS region to allow us to work with raster data (Menu: Plugins/GRASS/New Dataset)
    Create a new database, location name and projection (EPSG 2157) and accept the default region. Finally define a mapset name.
  7. Refine the GRASS region.
    From the ‘Region’ tab in the grass toolbox, drag an extent and then manually revise the coordinates and the resolution until the size matches exactly a 50m grid (see image below – in this image adjustment is still required for the coordinates to be rounded to the regular grid).

Ensure Attribution and Create a Gridded Version of the Data

  1. Although the contour data has been imported with 3D values (X,Y,Z) the next stage of the process requires that the Z value is an attribute (not just part of the geometry/coordinates).
    The “Field Calculator” from the toolbox can be used with a script to process this:
    z( start_point( $geometry ))
  2. Bringing the data to GRASS (GRASS Toolbox: v.in.ogr.qgis)
  3. Rasterising the contours (GRASS Toolbox: v.to.rast.attr)
    Using the ‘ZZZ’ attribute value from earlier.
  4. Creating a surface (GRASS Toolbox: r.surf.contour)
    The resultant grid (surface) interpolated between the rasterized contours is one step away from being exported to TrueViewVisuals. This surface process can take some time.


  1. SaveAs (Right-Click Layer/Save As…)
    In order to Export to ASC format (below) a physical file format is required.  Simply save as the default GeoTIFF format to facilitate this.
  2. Export (Menu Raster/Convsion/Translate (Convert Format…)
    From the options dialog, ensure a File format and ASC are selected for writing out.