Skip to content

Commit 5723de5

Browse files
committed
Coloured slope for e4MSTP
4th layer is coloured slope, it can be calculated directly in layer, so far it had a separate function. The function is now removed from tiled_multiprocessing as well.
1 parent adde1e0 commit 5723de5

File tree

2 files changed

+12
-46
lines changed

2 files changed

+12
-46
lines changed

examples/tiled_processing/tiled_multiprocess.py

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,6 @@ def blend_e3mstp(dict_arrays, save_path, save_float=False):
10181018

10191019

10201020
def blend_e4mstp(dict_arrays, save_path, save_float=False):
1021-
# Get Coloured Slope
1022-
dict_arrays['cs'] = blend_coloured_slope(dict_arrays)
10231021
# Get SVF combined
10241022
dict_arrays['svf_combined'] = blend_svf_combined(dict_arrays)
10251023
# Get Openness + LD
@@ -1045,10 +1043,11 @@ def blend_e4mstp(dict_arrays, save_path, save_float=False):
10451043
image=dict_arrays['opns_ld']
10461044
)
10471045
comb_nv.create_layer(
1048-
vis_method="coloured slope",
1049-
normalization="value", minimum=0, maximum=1,
1046+
vis_method="Slope gradient",
1047+
normalization="value", minimum=0, maximum=55,
10501048
blend_mode="normal", opacity=100,
1051-
image=dict_arrays['cs']
1049+
colormap="Reds_r", min_colormap_cut=0, max_colormap_cut=1,
1050+
image=dict_arrays['slp_1'].squeeze()
10521051
)
10531052
out_e4mstp = comb_nv.render_all_images(
10541053
save_visualizations=False,
@@ -1089,35 +1088,6 @@ def blend_e4mstp(dict_arrays, save_path, save_float=False):
10891088
return out_e4mstp
10901089

10911090

1092-
def blend_coloured_slope(dict_arrays, save_path=None):
1093-
# Coloured slope
1094-
comb_cs = rvt.blend.BlenderCombination()
1095-
comb_cs.create_layer(
1096-
vis_method="Slope gradient", normalization="Value",
1097-
minimum=0, maximum=55,
1098-
blend_mode="normal", opacity=100,
1099-
colormap="Reds_r", min_colormap_cut=0, max_colormap_cut=1,
1100-
image=dict_arrays['slp_1'].squeeze()
1101-
)
1102-
coloured_slope = comb_cs.render_all_images(
1103-
save_visualizations=False,
1104-
save_render_path=None,
1105-
no_data=np.nan
1106-
)
1107-
coloured_slope = coloured_slope.astype("float32")
1108-
1109-
if save_path:
1110-
# Save GeoTIF
1111-
rasterio_save(
1112-
coloured_slope,
1113-
dict_arrays['profile'],
1114-
save_path=save_path,
1115-
nodata=np.nan
1116-
)
1117-
1118-
return coloured_slope
1119-
1120-
11211091
def blend_opns_ld(dict_arrays, save_path=None):
11221092
"""Required dict_arrays:
11231093
- opns

rvt/blend.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ def e4mstp(dem, resolution, default: rvt.default.DefaultValues = rvt.default.Def
14081408
svf_arr = svf_temp["svf"].squeeze()
14091409
neg_opns_arr = default.get_neg_opns(dem, resolution).squeeze()
14101410

1411-
# For SVF 2 (FLAT)
1411+
# For SVF 2 (FLAT) # TODO: svf_r_max is in pixels, take into account the resolution
14121412
default_2 = rvt.default.DefaultValues()
14131413
default_2.svf_r_max = 20
14141414
default_2.svf_noise = 3
@@ -1437,14 +1437,14 @@ def e4mstp(dem, resolution, default: rvt.default.DefaultValues = rvt.default.Def
14371437
# 3) Comb openness LD
14381438
comb_ol = rvt.blend.BlenderCombination()
14391439
comb_ol.create_layer(
1440-
vis_method="Openness difference", normalization="Value",
1441-
minimum=-15, maximum=15,
1440+
vis_method="Openness difference",
1441+
normalization="Value", minimum=-15, maximum=15,
14421442
blend_mode="normal", opacity=50,
14431443
image=(opns_arr - neg_opns_arr)
14441444
)
14451445
comb_ol.create_layer(
1446-
vis_method="Local dominance", normalization="Value",
1447-
minimum=0.5, maximum=1.8,
1446+
vis_method="Local dominance",
1447+
normalization="Value", minimum=0.5, maximum=1.8,
14481448
blend_mode="normal", opacity=100,
14491449
image=ld_arr
14501450
)
@@ -1456,11 +1456,7 @@ def e4mstp(dem, resolution, default: rvt.default.DefaultValues = rvt.default.Def
14561456
comb_opns_ld_arr = comb_opns_ld_arr.astype("float32")
14571457

14581458
# 4) Coloured slope
1459-
slope_arr = rvt.vis.slope_aspect(
1460-
dem=dem,
1461-
resolution_x=resolution,
1462-
resolution_y=resolution,
1463-
)["slope"]
1459+
slope_arr = rvt.vis.slope_aspect(dem=dem, resolution_x=resolution, resolution_y=resolution)["slope"]
14641460
# ------------------------------------------------------------------------------------------------------------------
14651461

14661462
# Prepare layers for blending
@@ -1484,8 +1480,8 @@ def e4mstp(dem, resolution, default: rvt.default.DefaultValues = rvt.default.Def
14841480
image=comb_opns_ld_arr
14851481
)
14861482
blend_combination.create_layer(
1487-
vis_method="coloured slope",
1488-
normalization="value", minimum=0, maximum=1,
1483+
vis_method="Slope gradient",
1484+
normalization="value", minimum=0, maximum=55,
14891485
blend_mode="normal", opacity=100,
14901486
colormap="Reds_r", min_colormap_cut=0, max_colormap_cut=1,
14911487
image=slope_arr

0 commit comments

Comments
 (0)