<jupyter_start><jupyter_text>RVT default module Module rvt.default is meant to quickly calculate or save any rvt visualization (suitable for beginner python users). To calculate visualization we need visualization parameters (e.g. hillshade sun azimuth). Module default has a class rvt.default.DefultValues() where all visualization parameters are stored as attributes of this class. This class also contains methods to get (calculate) numpy array of specific visualization or to calculate and save specific visualization as GeoTIFF, all methods use class atributes (set parameters). For get methods we need dem numpy array, for save methods we need dem path. If you call save method for specific visualization (e.g. default.save_hillshade()) it will be saved in DEM (dem_path) direcotry, to change output directory you have to input output directory as string in custom_dir (save methods parameter). Save methods also have two boolean parameters save_float and save_8bit. If save_float is True method will save visulization as float and if save_8bit is True method will bytescale visualization (0-255) and save it. Both can be True to save both. Let's import modules:<jupyter_code>import matplotlib.pyplot as plt
import rvt.default<jupyter_output><empty_output><jupyter_text>To get visualization array we also need input DEM numpy array. We will use default module function get_raster_arr() to read it.<jupyter_code>dem_path = r"../test_data/TM1_564_146.tif"  # set path to your dem
dict_dem = rvt.default.get_raster_arr(dem_path)
dem_arr = dict_dem["array"]  # numpy array of DEM
dem_resolution = dict_dem["resolution"]
dem_res_x = dem_resolution[0]  # resolution in X direction
dem_res_y = dem_resolution[1]  # resolution in Y direction
dem_no_data = dict_dem["no_data"]

plt.imshow(dem_arr, cmap='gray')  # show DEM<jupyter_output><empty_output><jupyter_text>Create rvt.default.DefaultValues() class:<jupyter_code>default = rvt.default.DefaultValues()  # we created instance of class and stored it in default variable<jupyter_output><empty_output><jupyter_text>Our DEM (example DEM: TM1_564_146.tif) don't have noData pixels. This is why we will set fill_no_data and keep_original_no_data to False. We also won't define no_data in all get visualization methods.<jupyter_code>default.fill_no_data = False
default.keep_original_no_data = False<jupyter_output><empty_output><jupyter_text>Slope Gradient Set parameters:<jupyter_code>default.slp_output_units = "degree"<jupyter_output><empty_output><jupyter_text>Calculate numpy array:<jupyter_code>slope_arr = default.get_slope(dem_arr=dem_arr, resolution_x=dem_res_x, resolution_y=dem_res_y)
plt.imshow(slope_arr, cmap='gray')<jupyter_output><empty_output><jupyter_text>Calculate and save as GeoTIFF in DEM directory:<jupyter_code>default.save_slope(dem_path=dem_path, custom_dir=None, save_float=True, save_8bit=True)<jupyter_output>/home/kristof/.local/lib/python3.8/site-packages/rvt/blend_func.py:59: RuntimeWarning: invalid value encountered in greater
  image[image > maximum] = maximum
/home/kristof/.local/lib/python3.8/site-packages/rvt/blend_func.py:60: RuntimeWarning: invalid value encountered in less
  image[image < minimum] = minimum
/home/kristof/.local/lib/python3.8/site-packages/rvt/blend_func.py:64: RuntimeWarning: invalid value encountered in greater
  image[image > 1] = 1
/home/kristof/.local/lib/python3.8/site-packages/rvt/blend_func.py:65: RuntimeWarning: invalid value encountered in less
  image[image < 0] = 0
/home/kristof/.local/lib/python3.8/site-packages/rvt/vis.py:92: RuntimeWarning: invalid value encountered in greater
  byte_data[byte_data > high] = high
/home/kristof/.local/lib/python3.8/site-packages/rvt/vis.py:93: RuntimeWarning: invalid value encountered in less
  byte_data[byte_data < 0] = 0<jupyter_text>Hillshade Set parameters:<jupyter_code>default.hs_sun_el = 35 
default.hs_sun_azi = 315<jupyter_output><empty_output><jupyter_text>Calculate numpy array:<jupyter_code>hillshade_arr = default.get_hillshade(dem_arr=dem_arr, resolution_x=dem_res_x, resolution_y=dem_res_y)
plt.imshow(hillshade_arr, cmap='gray')<jupyter_output><empty_output><jupyter_text>Calculate and save as GeoTIFF in DEM directory:<jupyter_code>default.save_hillshade(dem_path=dem_path, custom_dir=None, save_float=True, save_8bit=True)<jupyter_output><empty_output><jupyter_text>Multiple directions hillshade Set parameters:<jupyter_code>default.mhs_nr_dir = 16
default.mhs_sun_el = 35<jupyter_output><empty_output><jupyter_text>Calculate numpy array:<jupyter_code>mhs_arr = default.get_multi_hillshade(dem_arr=dem_arr, resolution_x=dem_res_x, resolution_y=dem_res_y)<jupyter_output><empty_output><jupyter_text>Calculate and save as GeoTIFF in DEM directory:<jupyter_code>default.save_multi_hillshade(dem_path=dem_path, custom_dir=None, save_float=True, save_8bit=True)<jupyter_output><empty_output><jupyter_text>Simple local relief model Set parameters:<jupyter_code>default.slrm_rad_cell = 20<jupyter_output><empty_output><jupyter_text>Calculate numpy array:<jupyter_code>slrm_arr = default.get_slrm(dem_arr=dem_arr)
plt.imshow(slrm_arr, cmap='gray')<jupyter_output><empty_output><jupyter_text>Calculate and save as GeoTIFF in DEM directory:<jupyter_code>default.save_slrm(dem_path=dem_path, custom_dir=None, save_float=True, save_8bit=True)<jupyter_output><empty_output><jupyter_text>Multi-scale relief model Set parameters:<jupyter_code>default.msrm_feature_min = 1
default.msrm_feature_max = 5
default.msrm_scaling_factor = 3<jupyter_output><empty_output><jupyter_text>Calculate numpy array:<jupyter_code>msrm_arr = default.get_msrm(dem_arr=dem_arr, resolution=dem_res_x)
plt.imshow(msrm_arr, cmap='gray')<jupyter_output><empty_output><jupyter_text>Calculate and save as GeoTIFF in DEM directory:<jupyter_code>default.save_msrm(dem_path=dem_path, custom_dir=None, save_float=True, save_8bit=True)<jupyter_output><empty_output><jupyter_text>Sky-view factor, Anisotropic Sky-view factor, Positive - Openness Set parameters:<jupyter_code># parameters for all three
default.svf_n_dir = 16
default.svf_r_max = 10
default.svf_noise = 0
# parameters for asvf
default.asvf_dir = 315
default.asvf_level = 1<jupyter_output><empty_output><jupyter_text>Calculate numpy array:<jupyter_code>svf_asvf_opns_dict = default.get_sky_view_factor(dem_arr=dem_arr, resolution=dem_res_x,
                                                 compute_svf=True, compute_asvf=True, compute_opns=True)
svf_arr = svf_asvf_opns_dict["svf"]
plt.imshow(svf_arr, cmap='gray')
asvf_arr = svf_asvf_opns_dict["asvf"]
plt.imshow(asvf_arr, cmap='gray')
opns_arr = svf_asvf_opns_dict["opns"]
plt.imshow(opns_arr, cmap='gray')<jupyter_output><empty_output><jupyter_text>Calculate and save as GeoTIFF in DEM directory:<jupyter_code>default.save_sky_view_factor(dem_path=dem_path, save_svf=True, save_asvf=True, save_opns=True,
                             custom_dir=None, save_float=True, save_8bit=True)<jupyter_output><empty_output><jupyter_text>Negative - Openness Set parameters (svf_parameters):<jupyter_code>default.svf_n_dir = 16
default.svf_r_max = 10
default.svf_noise = 0<jupyter_output><empty_output><jupyter_text>Calculate numpy array:<jupyter_code>neg_opns_arr = default.get_neg_opns(dem_arr=dem_arr, resolution=dem_res_x)
plt.imshow(neg_opns_arr, cmap='gray')<jupyter_output><empty_output><jupyter_text>Calculate and save as GeoTIFF in DEM directory:<jupyter_code>default.save_neg_opns(dem_path=dem_path, custom_dir=None, save_float=True, save_8bit=True)<jupyter_output><empty_output><jupyter_text>Local dominance Set parameters:<jupyter_code>default.ld_min_rad = 10
default.ld_max_rad = 20
default.ld_rad_inc = 1
default.ld_anglr_res = 15
default.ld_observer_h = 1.7<jupyter_output><empty_output><jupyter_text>Calculate numpy array:<jupyter_code>local_dom_arr = default.get_local_dominance(dem_arr=dem_arr)
plt.imshow(local_dom_arr, cmap='gray')<jupyter_output><empty_output><jupyter_text>Calculate and save as GeoTIFF in DEM directory:<jupyter_code>default.save_local_dominance(dem_path=dem_path, custom_dir=None, save_float=True, save_8bit=True)<jupyter_output><empty_output><jupyter_text>Sky illumination Set parameters:<jupyter_code>default.sim_sky_mod = "overcast"
default.sim_compute_shadow = 0
default.sim_shadow_dist = 100
default.sim_nr_dir = 32
default.sim_shadow_az = 315
default.sim_shadow_el = 35<jupyter_output><empty_output><jupyter_text>Calculate numpy array:<jupyter_code>sky_illum_arr = default.get_sky_illumination(dem_arr=dem_arr, resolution=dem_res_x)
plt.imshow(sky_illum_arr, cmap='gray')<jupyter_output><empty_output><jupyter_text>Calculate and save as GeoTIFF in DEM directory:<jupyter_code>default.save_sky_illumination(dem_path=dem_path, custom_dir=None, save_float=True, save_8bit=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09463148316651501, 'fraction_numerical': 0.012397634212920837, 'mean_word_length': 8.485436893203884, 'pattern_counts': {'":': 0, '<': 127, '<?xml version=': 0, '>': 127, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '31', 'dir': 'jupyter-structured-clean-dedup', 'id': '145646', 'license': 'Apache-2.0', 'n_tokens_mistral': 3265, 'n_tokens_neox': 3094, 'n_words': 584, 'path': 'examples/rvt_default_example.ipynb', 'repo_name': 'H4estu/RVT_py', 'size': '8792'}