Skip to content

Commit 32aecd5

Browse files
authored
Allow Negative Target Height in Viewshed Analysis (viewshed.py) (#812)
Description: This pull request introduces support for negative target heights in the viewshed function. The modification ensures that target points can have a decreased z-value, which is particularly useful for cases where visibility analysis needs to account for building facades rather than rooftops. Reason for Change: When using the library for viewshed analysis from an observer in a tall building, the function primarily returns visible points on rooftops rather than building facades. Allowing negative target heights makes it possible to adjust the z-value of the target point while keeping all other points treated normally, improving accuracy in urban visibility studies.
1 parent 9a53c55 commit 32aecd5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

xrspatial/viewshed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ def _viewshed_cpu(
15381538
viewpoint_col = x_view
15391539
viewpoint_elev = raster.values[y_view, x_view] + observer_elev
15401540
viewpoint_target = 0.0
1541-
if target_elev > 0:
1541+
if abs(target_elev) > 0:
15421542
viewpoint_target = target_elev
15431543

15441544
# int getgrdhead(FILE * fd, struct Cell_head *cellhd)

0 commit comments

Comments
 (0)