The road to 3D Topography
This tutorial will illustrate the process of importing and transforming Digital Terrain Models (DTM) or Digital Surface Models (DSM) into a .xyz or .csv file for further manipulation. DTMs and DSMs are commonly provided by municipalities as base data for planning tasks. However they usually come in the format GeoTIFF, a geo-located picture format, that is incompatible with most CAD programs. To transform the file into a usable three-dimensional topography model, several transformation steps have to be undertaken in QGIS. These steps will be illustrated in the following.
Importing DTM / DSM to QGIS
Download a set of GeoTIFFs from a website of your choice. This tutorial will focus on the Klopstockwiese in Zurich from Zurich GIS.
Since larger datasets are usually divided into smaller tiles the download of the selected area as shown in the picture below will likely contain several tiles. In this case your download will include four .tif files.
Webpage of Zurich GIS, you can search for the location like 'Klopstockwiese' in the top left corner, and its below to find the map you need. Then you can click on the download button above the map and select the desired area to download.
After downloading the different tiles, they have to be unpacked and afterwards combined into one consistent raster file. For this step we are only interested in the .tif file from the download folder. Drag and drop those files into your QGIS workspace to load them. They are currently not connected and have their own colour range indication the height of that raster point. The breaks between the different sets are clearly visible below.
Window of QGIS, altenative to import GeoTIFF files:
Layer > Add Layer > Add Raster Layer
.
Merging Raster Layers
As previously mentioned, the downloaded content is typically separated into multiple files. We need to merge these files before proceeding to the next step.
Step 1: Go to
Raster > Miscellaneous > Merge
Step 2: Select the raster sets you would like to combine by clicking on the three dots in the top right corner.
Step 3: Select the maps you want to combine and press
OK
.
Correcting the Raster Values
After merging, there will be a new layer called 'Merged' in the layer panel. You might notice that the values of the new file are not the same as in the original files (compare the maximum and minimum raster values). This inconvenience can be solved by adjusting the layer properties.
Step 1: Select the 'Merged' raster layer,
right-click
on it and navigate toProperties
.
Step 2: Within the properties window navigate to
Symbology
and expand theMin / Max Value Settings
tab by clicking on it.
Step 3: Within the
Min / Max Value Settings
change the accuracy fromEstimate (faster)
toActual (slower)
. Click apply and close the properties window. Now the values should the same as your input layers.Note: This is a purely cosmetic adjustment. The true values are still saved in the raster, meaning QGIS just estimates them for display purposes.
Clipping the Raster Layer
After the combination, the next step is to limit the raster layer to the area we want to export. Please make sure to choose a rather small extent - the bigger the extent the more computational power is needed in the following steps.
Step 1: Select the 'merged' layer and go to
Raster > Extraction > Clip Raster by Extent
.
Step 2: In the field
Clipping extent
, click on the three points and chooseDraw on Canvas
. Alternatively you could use a preset rectangular shapefile as a clipping boundary. ClickRun
and close the window.
Step 3: Disable the merged layer; the clipped extent may appear somewhat like this..
From Raster to Point
Now you should have a new layer 'Clipped(extent)' in the layer panel, to turn our raster data into a point set which we can import and open in Rhinoceros 3D, we have to use the Processing Toolbox. The toolbox offers a wide range of geoprocessing tools and has a surprisingly good search function.
Step 1: To open the toolbox panel, go to
Processing > Toolbox
.
Step 2: Search for and use the tool
Raster values to points
.
Step 3: Click on the three dots in the to right to select the desired raster layer for the transformation.
Step 4: Select the 'Clipped (extent)' layer and press okay. For the
Type
field in the following window, choose(0) nodes
and pressRun
. The calculation might take a while.
Step 5: The result of this calcualtion should be a layer called 'Shapes', containing various points. Right-click on the layer 'Shapes' and select
Attribute Table
, you can have a look at the data of each point like the image shows.
Exporting Points as CSV
Now we are ready for exporting. Navigate to the 'Shapes' layer, right-click and select Export > Save Features As
.
Within the exporting panel perform the following actions:
- Select CSV (Comma Separated Values) as a file format.
- Select a place to save the file and give it a name
- Untick the box
ID
.- Click
OK
to start the export.
Final Adjustments
If you open the exported file in a text editor it will look somewhat like the screenshot below. To make this code readable for the Docofossor plugin we need to delete the first line (marked in the screenshot) and save the file again. If your file is too heavy to open in a text editor it is likely to be too heavy for any of the next steps. Crop the raster extend a bit more and try again.
Screenshot of the exported csv file