rvt.blend¶
Relief Visualization Toolbox – Visualization Functions
Contains classes and methods for blending.
- rvt.blend.create_blender_file_example(file_path=None)[source]¶
Create blender .json file example (can be changed and read). Example is VAT - Archaeological combination
- class rvt.blend.BlenderLayer(vis_method=None, normalization='value', minimum=None, maximum=None, blend_mode='normal', opacity=100, colormap=None, min_colormap_cut=None, max_colormap_cut=None, image=None, image_path=None)[source]¶
Bases:
objectClass which define layer for blending. BlenderLayer is basic element in BlenderCombination.layers list.
- vis¶
Visualization method.
- Type:
str
- normalization¶
Normalization type, could be “Value” or “Percent”.
- Type:
str
- min¶
Normalization minimum.
- Type:
float
- max¶
Normalization maximum.
- Type:
float
- opacity¶
Image (visualization) opacity.
- Type:
integer
- colormap¶
Colormap form matplotlib (https://matplotlib.org/3.3.2/tutorials/colors/colormaps.html).
- Type:
str
- min_colormap_cut¶
What lower part of colormap to cut to select part of colormap. Valid values are between 0 and 1, if 0.2 it cuts off (deletes) 20% of lower colors in colormap. If None cut is not applied.
- Type:
float
- max_colormap_cut¶
What upper part of colormap to cut to select part of colormap. Valid values are between 0 and 1, if 0.8 it cuts off (deletes) 20% of upper colors in colormap. If None cut is not applied.
- Type:
float
- image_path¶
Path to DEM. Doesn’t matter if image is not None. Leave None if you would like for blender to compute it.
- Type:
str
- image¶
Visualization raster. Leave None if you would like for blender to compute it.
- Type:
numpy.array (2D)
- class rvt.blend.BlenderCombination(dem_arr=None, dem_resolution=None, dem_path=None)[source]¶
Bases:
objectClass for storing layers (rasters, parameters for blending) and rendering(blending) into blended raster.
- dem_arr¶
Array with DEM data, needed for calculating visualization functions in memory.
- Type:
np.array (2D)
- dem_path¶
Path to DEM, needed for calculating visualization functions and saving them.
- Type:
str
- name¶
Name of BlenderCombination combination.
- Type:
str
- layers¶
List of BlenderLayer instances which will be blended together.
- Type:
- add_dem_arr(dem_arr, dem_resolution)[source]¶
Add or change dem_arr attribute and its resolution dem_resolution attribute.
- create_layer(vis_method=None, normalization='value', minimum=None, maximum=None, blend_mode='normal', opacity=100, colormap=None, min_colormap_cut=None, max_colormap_cut=None, image=None, image_path=None)[source]¶
Create BlenderLayer and adds it to layers attribute.
- add_layer(layer: BlenderLayer)[source]¶
Add BlenderLayer instance to layers attribute.
- save_to_file(file_path)[source]¶
Save layers (manually) to .json file. Parameters image and image_path in each layer have to be None, visualization has to be correct!
- render_all_images(default=None, save_visualizations=False, save_render_path=None, save_float=True, save_8bit=False, no_data=None)[source]¶
Render all layers and returns blended image. If specific layer (BlenderLayer) in layers has image (is not None), method uses this image, if image is None and layer has image_path method reads image from path. If both image and image_path are None method calculates visualization. If save_visualization is True method needs dem_path and saves each visualization (if it doesn’t exists) in directory of dem_path, else (save_visualization=False) method needs dem_arr, dem_resolution and calculates each visualization simultaneously (in memory). Be careful save_visualisation applies only if specific BlenderLayer image and image_path are None. Parameter no_data changes all pixels with this values to np.nan, if save_visualizations is Ture it is not needed.
- create_log_file(dem_path, combination_name, render_path, default: DefaultValues, terrain_sett_name=None, custom_dir=None, computation_time=None)[source]¶
Creates log file in custom_dir, if custom_dir=None it creates it in dem directory (dem_path).
- rvt.blend.compare_2_combinations(combination1: BlenderCombination, combination2: BlenderCombination)[source]¶
- class rvt.blend.BlenderCombinations[source]¶
Bases:
objectClass for storing combinations.
- combinations¶
List of BlenderCombination instances.
- Type:
- add_combination(combination: BlenderCombination, name=None)[source]¶
Adds combination if parameter name not None it renames combination.
- select_combination_by_name(name)[source]¶
Select first combination where self.combinations.BlenderCombination.name = name.
- remove_combination_by_name(name)[source]¶
Removes all combinations where self.combinations.BlenderCombination.name = name. If combinations list is empty function returns 0, else 1.
- combination_in_combinations(input_combination: BlenderCombination)[source]¶
If input_combination (BlenderCombination) has same attributes as one of the combinations (self), method returns name of the combination (from combinations). If there is no equal one it returns None.
- class rvt.blend.TerrainSettings[source]¶
Bases:
objectTerrain settings for GUI.
- apply_terrain(default: DefaultValues, combination: BlenderCombination)[source]¶
It overwrites default (DefaultValues) and combination (BlenderCombination), with self values that are not None.
- rvt.blend.color_relief_image_map(dem, resolution, default: DefaultValues = <rvt.default.DefaultValues object>, colormap='OrRd', min_colormap_cut=0, max_colormap_cut=1, no_data=None)[source]¶
RVT Color relief image map (CRIM) Blending combination where layers are: 1st: Openness positive - Openness negative, overlay, 50% opacity 2nd: Openness positive - Openness negative, luminosity, 50% opacity 3rd: Slope gradient, colored with matplotlib colormap
- Parameters:
dem (numpy.ndarray) – Input digital elevation model as 2D numpy array.
resolution (float) – DEM pixel size.
default (rvt.default.DefaultValues) – Default values for visualization functions.
colormap (str) – Colormap form matplotlib (https://matplotlib.org/3.3.2/tutorials/colors/colormaps.html).
min_colormap_cut (float) – What lower part of colormap to cut. Between 0 and 1, if 0.2 it cuts off (deletes) 20% of lower colors in colormap. If None cut is not applied.
max_colormap_cut (float) – What upper part of colormap to cut. Between 0 and 1, if 0.8 it cuts off (deletes) 20% of upper colors in colormap. If None cut is not applied.
no_data (int or float) – Value that represents no_data, all pixels with this value are changed to np.nan .
- Returns:
crim_out – 2D numpy result array of Color relief image map.
- Return type:
numpy.ndarray
- rvt.blend.e3mstp(dem, resolution, default: DefaultValues = <rvt.default.DefaultValues object>, no_data=None)[source]¶
RVT enhanced version 3 Multi-scale topographic position (e3MSTP) Blending combination where layers are: 1st: Simple local relief model (SLRM), screen, 25% opacity 2nd: Color relief image map where cmap=Reds_r(0.5-1) (CRIM_Reds_r), soft_light, 70% opacity 3rd: Multi-scale topographic position (MSTP)
- Parameters:
dem (numpy.ndarray) – Input digital elevation model as 2D numpy array.
resolution (float) – DEM pixel size.
default (rvt.default.DefaultValues) – Default values for visualization functions.
no_data (int or float) – Value that represents no_data, all pixels with this value are changed to np.nan .
- Returns:
e3mstp_out – 2D numpy result array of Color relief image map.
- Return type:
numpy.ndarray
- rvt.blend.e4mstp(dem, resolution, default: DefaultValues = <rvt.default.DefaultValues object>, no_data=None)[source]¶
RVT enhanced version 4 Multi-scale topographic position (e4MSTP) Blending combination where layers are: 1st: Multi-scale topographic position (MSTP), overlay, 90% opacity 2nd: Combined SFV, multiply, opacity=25
Sky-view factor(0.7 - 1), normal, opacity=50
Sky-view factor(0.9 - 1), normal, opacity=100
- 3rd: Combined Openness and Local Dominance, multiply, opacity=100
[Openness(-15 - 15) - Neg. Openness(-15 - 15)], normal, opacity=50
Local Dominance(0.5 - 1.8), normal, opacity=100
4th: Colored slope (0-55), cmap=Reds_r(0-1), normal, opacity=100
Note
Two different “defaults” settings are used. The first one, for general terrain is assigned at the function input (which reads the defaults.json file), the second one for flat terrain is called inside the function (can not be assigned by the user).
- Parameters:
dem (numpy.ndarray) – Input digital elevation model as 2D numpy array.
resolution (float) – DEM pixel size.
default (rvt.default.DefaultValues) – Default values for visualization functions.
no_data (int or float) – Value that represents no_data, all pixels with this value are changed to np.nan .
- Returns:
e4mstp_out – 2D numpy result array of Color relief image map.
- Return type:
numpy.ndarray