gemgis.visualization.create_dem_3d#

gemgis.visualization.create_dem_3d(dem: Union[rasterio.io.DatasetReader, numpy.ndarray], extent: List[Union[int, float]] = None, res: int = 1) pyvista.core.pointset.StructuredGrid#

Plotting the dem in 3D with PyVista

Parameters
  • dem (Union[rasterio.io.DatasetReader, np.ndarray]) – Rasterio object or NumPy array containing the height values

  • extent (List[Union[int, float]]) – List containing the bounds of the raster, e.g. extent=[0, 972, 0, 1069]

  • res (int) – Resolution of the meshgrid, e.g. resolution=1, default is 1

Returns

grid – Grid storing the elevation data

Return type

pyvista.core.pointset.StructuredGrid

New in version 1.0.x.

Example

>>> # Loading Libraries and File
>>> import gemgis as gg
>>> import rasterio
>>> raster = rasterio.open(fp='raster.tif')
>>> # Defining raster extent
>>> extent = [0, 972, 0, 1069]
>>> # Creating mesh from raster data
>>> grid = gg.visualization.create_dem_3d(dem=raster.read(1), extent=extent)
>>> grid
Header
            StructuredGrid  Information
N           Cells           1037028
N           Points          1039068
X           Bounds          0.000e+00, 9.710e+02
Y           Bounds          0.000e+00, 1.068e+03
Z           Bounds          2.650e+02, 7.300e+02
Dimensions                  1069, 972, 1
N Arrays                    1
Data Arrays
Name        Field   Type    N Comp  Min         Max
Elevation   Points  float64 1       2.656e+02   7.305e+02

See also

create_lines_3d_polydata

Creating a mesh from lines

create_points_3d

Creating a mesh from points