Advertisements

An original point of view

GIS, Relief

Elevation data in QGIS without DEM

QGIS elevation DEM from grid

In this article, I want to demonstrate to you some shortcut, which is a product of two traditional ways of collecting the elevation data for any project in QGIS.
The first way of collecting the elevation data in QGIS is by downloading and using the Digital Elevation Model from which this particular data can be extracted easily. The second way seems to be slightly longer, as a user needs an additional tool, which is Google Earth. By using this simple application with the terrain mode turned on, the elevation data can be assembled without a problem. There is in fact one demerit of this way, which is the protracted drawing of the line back and forth across the area in which we want to get the data (Pic. 1).

Google Earth elevation data Geodelta lab

Pic. 1 Getting elevation data from Google Earth by drawing the line with multiple of points (GeoDeltaLab/Youtube.com).

Obviously, we want to get as much detailed elevation data as possible, therefore the number of these points must be enormous at some point. It must take time to get them by drawing the shape like this.
Therefore I’ve decided to raise this issue in this paper by acquainting you with a much quicker method of elevation data collection.

Firstly let’s consider instances such as this. The elevation file from Google Earth must be saved in the .kml format, which is converted to the .gpx file thereafter. Along with the conversion, the elevation data is added. Everything is advised to be done by the GpxVisualizer tool, which appears to be the handiest open-source web-based tool for manipulation with .gpx files.

Let’s see two types of .kml file input: produced by Google Earth and produced outside of Google Earth – in QGIS. Both show two points in almost exactly the same places (Pic. 2, 3). The first one represents the simplest line produced in Google Earth, and the second one is just two points representing the scratch point layer in QGIS exported further as the .kml file.

Google Earth simplest path

QGIS basic point scratch layer

Pic. 2, 3 Basic layers produced in Google Earth (2-point line)(upper image) and QGIS (scratch point layer)(lower image) made almost exactly in the same place. Both were exported to the .kml file afterward.

Both files have been exported to the .kml file, where the Random path .kml was the Google Earth output and Random path2.kml was created by the QGIS scratch layer.
Next, as per many tutorials, both files have been uploaded to GPS Visualizer for the .gpx conversion with the “add elevation” option. Afterward, both have been downloaded and opened in the Notead++ application (Pic. 4).

Elevation Google Earth vs QGIS

Pic. 4 The comparison of .gpx code between two former .kml files where the first one was created in Google Earth and the second one in QGIS.

Both files have been converted from .kml to .gpx extension. The GPS Visualizer platform has added the elevation data to both of them. As you can see, the primary difference between these 2 files is just the decimal place! Beyond the difference with the .xml code, it clearly looks like the elevation data bounded within <ele> tags has been provided correctly. The GPS Visualizer has the elevation database coverage worldwide based on various DEM with location-based usage (Pic. 5).

GPS Visualizer DEM coverage

Pic. 5 The GPS Visualizer DEM coverage worldwide (Gpsvisualizer.com).

In practice, it means, that the .gpx conversion along with providing the elevation data can be used without third-party tools like Google Earth. In this case, instead of manually drawing the line, which is surely time-consuming, we can prepare the data much quicker by utilizing dedicated algorithms in QGIS. This is what is shown below.

Imagine, that we need to get the elevation data for the area bounded in red as presented below (Pic. 6).

QGIS area

Pic. 6 Estimated area of our work in QGIS.

In QGIS there is a nice algorithm, which can be run straight from the Processing Toolbox – Create Grid (Pic. 7). Next, we must set up the type of grid (advisable in point layer) area, and space (usually in meters) between the points. Make sure, that you are making selections on the map canvas manually because otherwise, your QGIS might crash when you specify too small distances between the points. This is a dependency between the overall area selected and the space provided. For one plot of land, it can be even 2m, for a whole town it must be something about 20m. The upper limit of it is the 10MB size of exported .kml file from QGIS, which can be further converted by GPS Visualizer.

QGIS create point grid

Pic. 7 Creating a point grid in QGIS, where: 1 – Launching the algorithm from Processing Toolbox, 2 – selecting an area on map canvas; 3 – Visual range of our selection; 4 – Defining vertical and horizontal spaces between the grid points; 5 – Final output.

When everything is alright, as shown in the picture above you can export your output as the .kml file. Remember about changing the CRS system to WGS84  which is used by Keyhole Markup Language (Pic. 8).

QGIS export grid file as kml

Pic. 8 Exporting our grid output as the .kml file, where: 1 – file format, 2 – file name & path; 3 – the WGS84 CRS system, which is mandatory for the .kml extension.

Next, open the Elevation converter in the GPS Visualizer platform, upload your file there and convert it to .gpx along with adding elevation data (Pic. 9).

Gps Visualizer .kml file conversion

Pic. 9 Converting .kml file to .gpx file in GPS Visualizer with adding elevation data to it, where: 1 – The Upload a file button, 2 – The Convert & Add elevation button.

The black side of the conversion is quite a robust description section, admittedly with nothing special, which just overtaxes our .gpx file and might extend the conversion slightly, when the .kml input is large (Pic. 10).

GPS Visualizer conversion output

Pic. 10 The GPS Visualizer output with some junk data within the tag. The download option is above.

In general, we shouldn’t worry about this and just download the file available above. Afterward, we can change its name optionally.

The .gpx file can be added to QGIS easily by using Vector-> Add Vector Layer -> Source (selecting Vector Dataset). Bear in mind, that you don’t need all these separate layers included in the .gpx file. The savvy users notice, that all of them are empty apart from the Waypoints, where all the points have been included. Instead of Select All we should pick up just the last layer (Pic. 11).

QGIS loading .gpx file

Pic. 11 Loading our .gpx file to QGIS where only one layer (the last one) needs to be selected.

Once imported, the box with our point grid will appear again (assuming, that you’ve removed the previous scratch one). By looking at the attribute table you will spot, that the “ele” column has been created with the elevation data assigned for each point regardless of their total number in the grid polygon (Pic. 12).

QGIS grid point layer .gpx file

Pic. 11 The grid point layer imported to QGIS as the .gpx file with the elevation data provided by the GPS Visualizer tool.

Optionally you can move this point layer out of the group, but it’s not necessary.

Your next step will be finding and running the TIN Interpolation algorithm from Processing Toolbox. There are a few important options to set here. You need especially to pick up the correct layer to which the interpolation refers. It’s your recently added layer by importing the .gpx file. Besides the layer itself, the most important is specifying the attribute column, which in our case will be “ele” including elevation data for each point. A further step is precising the area of interpolation, which should be restricted to the layer imported as the .gpx file. Finally, our output raster size should have at least 10 rows if we wish to have quite reliable results (Pic. 12).

QGIS TIN Interpolation from .gpx file

Pic. 12 The TIN interpolation options, where: 1 – Defining the layer (A) and data (column)(B) used for interpolation purposes. Next, it must be added to the schedule by using the green “+” symbol (C); 2 – Determining the range of interpolation (A), which should be defined by “Using Layer Extends” (B) with the selection of our layer imported as .gpx file (C); 3 – Specifying the total number of rows (not less than 10).

When you are sure, that all the options have been picked up correctly, just hit “Run” and wait a while until the algorithm is finished. You should have the raster scratch layer called “Interpolated” emerged in the layer panel (unless you’ve defined its name and path earlier, but it’s not needed that much) and something like DEM appearing instead of our grid box (Pic. 13), which should have been brought beyond this raster layer or switched off for the time being. Otherwise, you might think, that the interpolation wasn’t successful.

QGIS TIN interpolated layer

Pic. 13 The result of TIN interpolation in QGIS from the grid point layer with elevation added. The raster layer has been produced from 20 rows.

Here is the moment, where you could make some changes with respect to the raster coloration, but it’s not necessary, to be honest. Important is the extraction of contours from our interpolated layer. For this purpose go Raster -> Extraction -> Contour and specify the contour cutting (Pic. 14), which is the only thing to worry about in the panel.

QGIS extract contours from interpolation

Pic. 14 Extraction contours from a raster in QGIS with specifying the contours cutting interval.

Wait for a moment and you should see the contour lines produced roughly above your raster layer. By playing with styling and labels you can customize them in some approachable manner (Pic. 15).

QGIS contour lines syled

Pic. 15 Basic customizations of the extracted contour lines in QGIS.

Obviously, if you think, that it’s not enough you can always repeat the Extract Contours algorithm in order to provide another, more general contours cutting to your area as shown in the output below (Pic. 16).

QGIS elevation data

Pic. 16 The finalized elevation data in QGIS after applying and styling another contour cutting (upper image) and removing the interpolated raster layer (lower image).

You can also remove the scratch raster layer produced by interpolation and have just the contour lines overlapped with your map canvas.

Mariusz Krukar

References:

  1. Wang Y., et al, 2017, Google Earth elevation data extraction and accurracy assesment for transportation applications, (in:) PLoS ONE 12(4)

Links:

  1. https://docs.qgis.org/3.22/en/docs/training_manual/rasters/terrain_analysis.html
  2. https://data.nextgis.com/en/howto/elevation_qgis/
  3. https://giscrack.com/building-a-qgis-3-digital-elevation-model/
  4. https://giscrack.com/working-with-elevation-data-in-qgis/
  5. https://www.alphr.com/show-elevation-in-google-earth/
  6. https://techplugged.com/how-to-get-the-elevation-on-google-earth/
  7. https://www.agiratech.com/how-to-generate-digital-elevation-model-using-google-earth-pro
  8. https://www.esurveycad.com/online/extract-elevation-from-google-earth
  9. https://mapscaping.com/5-websites-that-find-elevation-for-any-point-on-earth/
  10. https://www.lifewire.com/find-elevation-on-google-maps-5198524
  11. https://mathgis.blogspot.com/2009/07/extract-elevation-data-from-google.html
  12. https://www.gpsvisualizer.com/elevation
  13. https://www.gpsvisualizer.com/DEM_coverage.php

Forums:

  1. https://gis.stackexchange.com/questions/238372/extracting-elevation-data-from-dem-files-using-qgis
  2. https://www.researchgate.net/post/How-to-make-an-accurate-Digital-Elevation-Model-DEM-using-QGIS
  3. https://gis.stackexchange.com/questions/317534/how-do-i-add-elevation-data-to-my-layer
  4. https://gis.stackexchange.com/questions/28190/extracting-google-earth-elevation-data-to-excel
  5. researchgate.net/post/How_can_we_extract_digital_elevation_data_from_Google_Earth
  6. https://superuser.com/questions/272460/is-there-a-way-to-extract-elevation-data-from-google-earth/
  7. https://www.rockware.com/forum/index.php?/topic/2542-extract-elevation-from-google-earth/
  8. https://groups.google.com/g/kml-support-getting-started/c/NouM02EsCvY
  9. https://asksawal.com/how-to-extract-elevation-from-google-earth-31020
  10. https://www.quora.com/How-accurate-is-Google-Earth%E2%80%99s-elevation
  11. https://gis.stackexchange.com/questions/20259/what-datum-reference-ellipsoid-does-google-earth-use

Wiki:

  1. QGIS_Extract_Ground_Elevation

Youtube:

 

Advertisements

Leave a Reply