gemgis.visualization.drape_array_over_dem
gemgis.visualization.drape_array_over_dem#
- gemgis.visualization.drape_array_over_dem(array: numpy.ndarray, dem: Union[rasterio.io.DatasetReader, numpy.ndarray], extent: List[Union[int, float]] = None, zmax: Union[float, int] = 10000, resize_array: bool = True)#
Creating grid and texture to drape array over a digital elevation model
- Parameters
array (np.ndarray) – Array containing the map data such as a WMS Map
dem (Union[rasterio.io.DatasetReader, np.ndarray]) – Digital elevation model where the array data is being draped over
extent (List[Union[float, int]]) – List containing the bounds of the raster, e.g.
extent=[0, 972, 0, 1069]
zmax (Union[float, int]) – Maximum z value to limit the elevation data, e.g.
zmax=1000
resize_array (bool) – Whether to resize the array or the dem if the shape of the dem does not match the shape of the array Options include:
True
orFalse
, default set toTrue
- Returns
mesh (pyvista.core.pointset.PolyData) – Mesh containing the Digital elevation model data
texture (pyvista.core.objects.Texture) – PyVista Texture containing the map data
New in version 1.0.x.
Changed in version 1.1: Function now allows rasters with different sizes and resizes one of the rasters automatically
Changed in version 1.1.2: Edit zmax value and fixing a bug with the scikit-image resize function, see https://github.com/cgre-aachen/gemgis/issues/303
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> array array([[[ 93, 93, 126], [104, 104, 133], [227, 227, 234], ..., [152, 178, 204], [160, 188, 201], [206, 200, 181]], [[247, 246, 248], [241, 240, 246], [243, 241, 241], ..., [150, 177, 205], [175, 187, 177], [232, 228, 219]]], dtype=uint8)
>>> # Inspecting Digital Elevation Model values >>> dem array([[ 0. , 0. , 0. , ..., 40.1 , 40.09, 44.58], [ 0. , 0. , 0. , ..., 40.08, 40.07, 44.21], [ 0. , 0. , 0. , ..., 40.14, 44.21, 43.98], ..., [100.56, 102.14, 102.17, ..., 0. , 0. , 0. ], [ 99.44, 99.85, 99.77, ..., 0. , 0. , 0. ], [ 88.32, 91.76, 98.68, ..., 0. , 0. , 0. ]], dtype=float32)
>>> # Draping mesh over array >>> mesh, texture = gg.visualization.drape_array_over_dem(array=array, dem=dem) >>> mesh Header StructuredGrid Information N Cells 5595201 N Points 5600000 X Bounds 3.236e+07, 3.250e+07 Y Bounds 5.700e+06, 5.800e+06 Z Bounds 0.000e+00, 5.038e+02 Dimensions 2000, 2800, 1 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Texture Coordinates Points float32 2 -7.077e-06 1.000e+00
>>> # Inspecting the texture >>> texture (Texture)00000151B91F3AC0
See also
read_raster
Reading Digital Elevation Model as xarray
convert_to_rgb
Converting bands to RGB values for plotting