makepath / xarray-spatial

Raster-based Spatial Analytics for Python
https://xarray-spatial.readthedocs.io/
MIT License
846 stars 85 forks source link

Simple fix: Allow for negative target elevation. #808

Open trygvels opened 2 months ago

trygvels commented 2 months ago

Author of Proposal:

Reason or Problem

I use the library to carry out viewshed analyses from an observer in a tall building, to see if they can see the facade of buildings around a city. However, running the viewshed function using DOM data. However, most of the visible points returned correspond to rooftops, and not actual building facades.

Proposal

To deal with this problem, it would be useful to be able to pass a negative target height, so that all other points are treated normally, but the target point has a decreased z-value.

Design: Implementing this should be simple, if I am understanding the code correctly. It should simple be a case of changing the following if statement: if target_elev > 0: to iff abs(target_elev) > 0: for the _viewshed_cpu - case.

I have done this in my local version of the code, but if you agree that this solves my issue, than it would be great if it was included in a future version.

If you want, I can also do a pull request.