46 Working with HGT Files in GemGIS#

A file with the HGT file extension is a Shuttle Radar Topography Mission (SRTM) Data file. HGT files contain digital elevation models, which are 3D pictures of a surface, usually a planet, obtained during the Shuttle Radar Topography Mission (SRTM) by NASA and the National Geospatial-Intelligence Agency (NGA).

This data can easily be opened using rasterio.

ee608df99176491d8db2608e38facdd7

Source: https://www.lifewire.com/hgt-file-2621580#:~:text=A%20file%20with%20the%20HGT,%2DIntelligence%20Agency%20(NGA).

Set File Paths and download Tutorial Data#

If you downloaded the latest GemGIS version from the Github repository, append the path so that the package can be imported successfully. Otherwise, it is recommended to install GemGIS via pip install gemgis and import GemGIS using import gemgis as gg. In addition, the file path to the folder where the data is being stored is set. The tutorial data is downloaded using Pooch (https://www.fatiando.org/pooch/latest/index.html) and stored in the specified folder. Use pip install pooch if Pooch is not installed on your system yet.

[1]:
import gemgis as gg

file_path ='data/46_working_with_hgt_files_in_gemgis/'
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\ale93371\Anaconda3\envs\test_gempy\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
  warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
[2]:
gg.download_gemgis_data.download_tutorial_data(filename="46_working_with_hgt_files_in_gemgis.zip", dirpath=file_path)
Downloading file '46_working_with_hgt_files_in_gemgis.zip' from 'https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2F46_working_with_hgt_files_in_gemgis.zip' to 'C:\Users\ale93371\Documents\gemgis\docs\getting_started\tutorial\data\46_working_with_hgt_files_in_gemgis'.

Load HGT Data#

The HGT data can easily be loaded using Rasterio.

[2]:
import rasterio

raster = rasterio.open(file_path + 'N50E006.hgt')
raster
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\ale93371\Anaconda3\envs\test_gempy\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
  warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
[2]:
<open DatasetReader name='../../../../gemgis_data/data/46_working_with_hgt_files_in_gemgis/N50E006.hgt' mode='r'>

Plotting the data#

The data can be plotted like rasters from tif files.

[3]:
import matplotlib.pyplot as plt

plt.imshow(raster.read(1))
[3]:
<matplotlib.image.AxesImage at 0x2927f990130>
../../_images/getting_started_tutorial_46_working_with_hgt_files_in_gemgis_7_1.png