Skip to content

Commit ef6b6a4

Browse files
authored
Update e4mstp() in blend.py
Fixing bugs found when running qgis plugin
1 parent 455e8b7 commit ef6b6a4

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

rvt/blend.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ def e3mstp(dem, resolution, default: rvt.default.DefaultValues = rvt.default.Def
13661366
return e3mstp_out
13671367

13681368

1369-
def e4mstp(dem, resolution, default: rvt.default.DefaultValues = rvt.default.DefaultValues(), no_data=None):
1369+
def e4mstp(dem, resolution, default: rvt.default.DefaultValues=rvt.default.DefaultValues(), no_data=None):
13701370
"""
13711371
RVT enhanced version 4 Multi-scale topographic position (e4MSTP)
13721372
Blending combination where layers are:
@@ -1416,7 +1416,7 @@ def e4mstp(dem, resolution, default: rvt.default.DefaultValues = rvt.default.Def
14161416

14171417
# SVF for flat terrain (settings hardcoded, instead of importing second defaults.json)
14181418
default_2 = rvt.default.DefaultValues()
1419-
default_2.svf_r_max = 10 / resolution # i.e. 10 meters for flat terrain
1419+
default_2.svf_r_max = int(10 / resolution) # i.e. 10 meters for flat terrain
14201420
default_2.svf_noise = 3
14211421
svf_flat = default_2.get_sky_view_factor(dem, resolution, compute_svf=True, compute_opns=False)["svf"].squeeze()
14221422

@@ -1425,19 +1425,23 @@ def e4mstp(dem, resolution, default: rvt.default.DefaultValues = rvt.default.Def
14251425

14261426
# 2) Comb svf
14271427
comb_svf = rvt.blend.BlenderCombination()
1428-
comb_svf.create_layer(vis_method="Sky-view factor", normalization="Value",
1429-
minimum=0.7, maximum=1,
1430-
blend_mode="normal", opacity=50,
1431-
image=svf_arr
1432-
)
1433-
comb_svf.create_layer(vis_method="Sky-view factor", normalization="Value",
1434-
minimum=0.9, maximum=1,
1435-
blend_mode="normal", opacity=100,
1436-
image=svf_flat
1437-
)
1438-
cs_svf = comb_svf.render_all_images(save_visualizations=False,
1439-
save_render_path=None,
1440-
no_data=np.nan)
1428+
comb_svf.create_layer(
1429+
vis_method="Sky-view factor",
1430+
normalization="Value", minimum=0.7, maximum=1,
1431+
blend_mode="normal", opacity=50,
1432+
image=svf_arr
1433+
)
1434+
comb_svf.create_layer(
1435+
vis_method="Sky-view factor",
1436+
normalization="Value", minimum=0.9, maximum=1,
1437+
blend_mode="normal", opacity=100,
1438+
image=svf_flat
1439+
)
1440+
cs_svf = comb_svf.render_all_images(
1441+
save_visualizations=False,
1442+
save_render_path=None,
1443+
no_data=np.nan
1444+
)
14411445
comb_svf_arr = cs_svf.astype("float32")
14421446

14431447
# 3) Comb openness LD
@@ -1494,10 +1498,14 @@ def e4mstp(dem, resolution, default: rvt.default.DefaultValues = rvt.default.Def
14941498
)
14951499

14961500
# Run blend
1497-
e4mstp_out = blend_combination.render_all_images()
1501+
e4mstp_out = blend_combination.render_all_images(
1502+
save_visualizations=False,
1503+
save_render_path=None,
1504+
no_data=np.nan
1505+
)
14981506

14991507
# Postprocessing
15001508
if no_data is not None:
1501-
e4mstp_out[np.isnan(dem)] = no_data
1509+
e4mstp_out[:, np.isnan(dem)] = no_data
15021510

15031511
return e4mstp_out

0 commit comments

Comments
 (0)