Three-dimensional visualisation of terrain data from digital elevation models (DEMs) or climate model topography with PyVista. A set of Python example scripts illustrates how this data can be plotted for various domains and with auxiliary information.
When you use Terrain3D, please cite:
The following Python packages are required to run Terrain3D: NumPy, SciPy, Xarray, Numba, Shapely, descartes, Fiona, Rasterio, tqdm, requests, PyVista, Matplotlib, pyproj, cmcrameri, netCDF4, cartopy, xESMF, scikit-image and Pillow. Combining the individual output images of the example scripts tri_mesh_globe.py and triangles_terrain_horizon.py into a movie or GIF requires FFmpeg or ImageMagick, respecitvely.
First, create a Conda environment with all the required Python packages:
conda create -n terrain3d -c conda-forge numpy scipy matplotlib netcdf4 shapely xarray pyproj cartopy rasterio descartes fiona scikit-image numba xesmf cmcrameri tqdm requests pyvista pillow
and activate this environment. The Terrain3D package can then be installed with:
git clone https://github.com/ChristianSteger/Terrain3D.git
cd Terrain3D
python -m pip install .
Known issues
Under Mac OS X, the current default version of xESMF that is installed with Conda might cause problems. This can be resolved by installed a specific version (xesmf=0.7.0) and adding
import os
os.environ["ESMFMKFILE"] = "<specify path to file 'esmf.mk'; something like ../miniconda3/envs/terrain3d/lib/esmf.mk>"
import xesmf as xe
to visualisation scripts, in which the xESMF library is imported.
A number of examples scripts are provided in the folder visualisation:
-
tri_mesh_globe.py: Visualise entire GEBCO data set on sphere with a triangle mesh. The elevation of quad vertices, which are below sea level and are land according to the GSHHG data base, are set to 0.0 m. Ice covered quads (land glaciers or ice shelves) are represented as white areas.
-
tri_mesh_vertical_grid.py: Visualise GEBCO or MERIT data for subregion in Switzerland with a triangle mesh. Use a planar map projection and display 'idealised' vertical grid of a GCM/RCM. Optionally display lakes.
-
tri_mesh_terrain_horizon.py: Visualise MERIT data for a subregion in Switzerland with a triangle mesh on a planar map projection. Illustrate the algorithm to compute terrain horizon (according to HORAYZON) in an animation. Combining the invividual images of the animation into a movie or GIF requires FFmpeg or ImageMagick, respecitvely.
-
tri_mesh_cosmo_multi.py: Visualise COSMO topography for the Hengduan Mountains (Southeastern Tibetan Plateau) with a triangle mesh. Plot three different topographies (present-day, reduced and envelope).
-
tri_mesh_aster_icon_radar.py: Visualise raw ASTER 30 m DEM and ICON 1km topography with radar location.
-
rect_columns_gebco.py: Visualise GEBCO data set with rectangular columns (→ terrain representation in climate models). The elevation of grid cells, which are below sea level and are land according to the GSHHG data base, are set to 0.0 m. Lakes can optionally be displayed.
-
rect_columns_gebco_res_ch.py: Visualise GEBCO data set for Switzerland with rectangular columns (→ terrain representation in climate models). The elevation of grid cells, which are below sea level and are land according to the GSHHG data base, are set to 0.0 m. Lakes are additionally displayed. Different spatial resolutions are visualised.
-
rect_columns_gebco_res_eu.py: Visualise GEBCO data set for Middle/South Europe with rectangular columns (→ terrain representation in climate models). The elevation of grid cells, which are below sea level and are land according to the GSHHG data base, are set to 0.0 m. Different spatial resolutions are visualised.
-
rect_columns_cosmo_vertical_grid.py: Visualise COSMO topography for a subregion of the Alps with rectangular columns. Vertical height-based hybrid (Gal-Chen) coordinates are additionally represented.
The following DEM data is available in Terrain3D:
And the following auxiliary data is applied:
- GSHHG
- Natural Earth - Glaciated Areas
- Natural Earth - Antarctic Ice Shelves
- swissTLMRegio - Swiss lake outlines
In case of issues or questions, contact Christian R. Steger ([email protected]). Please report any bugs you find in Terrain3D. You are welcome to fork this repository to modify the source code.