Library using QGIS, QT API and C++20 features to calculate visibility (viewshed), inverse visibility and additional information about it. The library is developed and tested on Linux.
The core of the functionality is in the library itself that can be used directly from C++, however the project defines also couple of binaries to simply use of tool.
There are two command line utilies: viewshed
and inverseviewshed
.
Usage: viewshed [options]
Viewshed.
Options:
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific
options.
-v, --version Displays version information.
--dem < > Raster file representing DEM for viewshed
calculation.
--resultsFolder < > Output folder to store the results in.
--observerPosition < > Observer position in for XXX.XX;YY.YYY .
--heightObserver < > Height of the observer.
--useCurvatureCorrections <true> Use curvature corrections?
--refractionCoefficient <0.142860> Refraction coefficient.
--earthDiameter <12740000> Earth diameter.
--visibilityMask < > Raster file representing visibility mask,
specifying areas to calculate visibility
in, for viewshed calculation.
Usage: inverseviewshed [options]
InverseViewshed.
Options:
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific
options.
-v, --version Displays version information.
--dem < > Raster file representing DEM for viewshed
calculation.
--resultsFolder < > Output folder to store the results in.
--targetPosition < > Target position in for XXX.XX;YY.YYY .
--heightObserver < > Height of the observer.
--heightTarget <0> Height of the target.
--useCurvatureCorrections <true> Use curvature corrections?
--refractionCoefficient <0.142860> Refraction coefficient.
--earthDiameter <12740000> Earth diameter.
--visibilityMask < > Raster file representing visibility mask,
specifying areas to calculate visibility
in, for viewshed calculation.
Besides that there are two binaries with GUI: viewshedcalculator
and losextractor
. That allow calculation of viewshed (and also inversviewshed) and its characteristics, and extraction of line-of-sight in form of CSV file.
The easiest way to test the library is using the docker image. The docker contains all the necessities for running the library (QGIS with dependencies including Qt and other libraries), thus its relatively bigger size.
It is probably a reasonable idea to attach the data using docker volumes to use your data inside the docker with the provided tools.
The individual command line tools can be run as:
docker run --rm -it -v /path/to/data:/path/to/data/in/docker cahik/viewshed:latest viewshed [parameters]
docker run --rm -it -v /path/to/data:/path/to/data/in/docker cahik/viewshed:latest inverseviewshed [parameters]
Running the GUI tools is slightly more complicated, as display has to be configured. On Linux it looks like this:
xhost +
docker run --rm -it --name viewshedcalculator \
-v /path/to/data:/path/to/data/in/docker \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY cahik/viewshed:latest viewshedcalculator
xhost -
xhost +
docker run --rm -it --name losextractor \
-v /path/to/data:/path/to/data/in/docker \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY cahik/viewshed:latest losextractor
xhost -
On distributions based on Debian, the tools can be installed from PPA.
sudo add-apt-repository ppa:jancaha/gis-tools
sudo apt-get update
apt-get -y install simplerasters viewshed viewshed-bin
If you use the library, please cite it accordingly:
@Software{Caha2024,
author = {Jan Caha},
title = {viewshed ({C++ Viewshed library based on GDAL and Qt})},
year = {2024},
date = {2024-07-11},
version = {4.0.3},
url = {https://github.com/JanCaha/cpp-viewshed-library},
}