Topo calculations like gradient and sky view
Project description
topocalc
The topocalc
package is a collection of functions to calculate various metrics on a digital elevation model (DEM). The calculations follow the equations laid out in Dozier and Frew, 1990 for the gradient, horizon and sky view factor. Currently the supported calculations are:
- Gradient for slope and aspect
- Horizon angles for an azimuth
- Sky view factor for percent of the sky that is visible from a point on the DEM
Background
Azimuth convention
For the azimuth's and aspects, the convention is that South is 0 degrees (0 radians) with positive values to the East (+90 degrees or pi/4 radians) and negative values to the West (-90 degrees or -pi/4 radians). North is -180 degrees or -pi/2.
Gradient for slope and aspect
The gradient method calculates the slope and aspect of the input DEM. There are two methods in topocalc.gradient
the gradient_d4
and gradient_d8
.
gradient_d4
mimics the slope and aspect calculations of the IPW gradient
function. This calculates the slope for a finite difference in just the x/y direction.
gradient_d8
(the default) uses a second order finite difference for a 3x3 square around a given point on the DEM.
The gradient is used to calculate the aspect from North (0 degrees). A conversion function will take the aspect in degrees and convert to radians with South being 0.
Horizon angles
The horizon angle for a point on the DEM is the angle from zenith to the horizon for a given azimuth. Following the methods laid out in Dozier and Frew, 1990 and in IPW horizon
the grid is rotated in the direction of the azimuth to make it a one dimensional problem.
For two points i
and j
, we compare the slope from i
and j
with the slope of j
's horizon. If the slope is greater, then all points past j
are not visible. If the slope is less, then all points between i
and j
don't need to be checked and the search can continue past point j
. This search is performed in C to significantly speed up the computation.
The values reported from horizon
are cosine of the horizon angle.
Sky view factor
The sky view factor (svf
) is the amount of the sky that is visible to a particular point. The svf
is between 0 and 1 with 1 indicating no obstructions from surrounding terrain and 0 indicating full obstruction. The svf
uses the slope, aspect and horizon angles for 72 directions to estimate the sky view factor for the DEM.
Usage
Installation
NOTE:
topocalc
has only been tested for Python 3.5 to 3.8 on Linux and MacOSX environments.
To install:
pip install topocalc
Gradient usage
from topocalc.gradient import gradient_d8
# Load the DEM into a numpy array
dem = load_dem(path_to_dem)
# grid cell spacing for the DEM
dem_dx = 30
dem_dy = 30
slope, aspect = gradient_d8(dem, dem_dx, dem_dy)
Sky view factor usage
from topocalc.viewf import viewf
# Load the DEM into a numpy array
dem = load_dem(path_to_dem)
# grid cell spacing for the DEM
dem_spacing = 30
svf, tvf = viewf(dem, spacing=dem_spacing)
Command Line Interface
Comming soon!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for topocalc-0.3.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e296791f9a2a7be3dfc3ab60ad99dd0513df68af2684e109743621e6f9cb0fc6 |
|
MD5 | 577ac0212c93e394a2b4b7c8f97317ad |
|
BLAKE2b-256 | f30fc4906c4401d15874f732b090496e57985782a45247be0117e9f67aea0fc1 |
Hashes for topocalc-0.3.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18691d1f2f7dee99f26b077b35f179219f13d433cc2fc54a75ebdf44f766b72b |
|
MD5 | 046e113c8b1090fd7049dd0e4ce3344f |
|
BLAKE2b-256 | 0dc1569814dc384e48cb9fa57eb97978869f6ce1a8ffd88a8c1cbf0390010f7a |
Hashes for topocalc-0.3.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0a834a20bd455448bb0d00813a380cf60ff6c70a2a8c5fd974b14d66f6d15cf |
|
MD5 | 5b6d0d60301dda45dc05d69a3093b0a3 |
|
BLAKE2b-256 | 60713e521e7d82325b3be0e15e97dd0fdb46d0b098ca4fd8b73a09dc5c32e355 |
Hashes for topocalc-0.3.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5d6157c94224cacf92bb851f6f62f5ff17a049b3c2a3b23fe6416e3190d1055 |
|
MD5 | 4e4712e110780cd2a1dab7c5a315fff8 |
|
BLAKE2b-256 | ab534070afc888c2f9cd4cef3339402cd66d35cd1a9d42e3114798dac6678106 |
Hashes for topocalc-0.3.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 503270cf4fd40a58672ddc3814c0fd70355bed5f803a23b92aba497ae9b92f73 |
|
MD5 | 53e54542e3882fc4574e7a29cf7739fc |
|
BLAKE2b-256 | dc89aeac169cd2ade0c7d973c9b168273215394ed8baa4d9dfb3b03b2894d60e |
Hashes for topocalc-0.3.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55e7bf2c2c5bd922e62b920b502dd9ca470886aa3dee625d7c6d82f118ad56c2 |
|
MD5 | 448590977454dba181e8ca1d5afff4f0 |
|
BLAKE2b-256 | 14591d30638c30e1a0dd3fc5bc30d3e8e2e24b91bf0847737932bad2088b5253 |
Hashes for topocalc-0.3.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 092974d2c3e74b371794d71da7514dcf2313540548100b135c0600130b9a7505 |
|
MD5 | 11775b91f49fc31305a3ced256d4e1d3 |
|
BLAKE2b-256 | b32db6f5db213bbad52f24e131ee130ca74eb148baa69d7cf20c721b7d0b3c4a |
Hashes for topocalc-0.3.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf463608f0d02a422deab332d9cf06a92deb4c855e1cfe1e3f2a9d7a9b5e7178 |
|
MD5 | b23b8283048c69f537cc6fe77c5977a7 |
|
BLAKE2b-256 | 70f135e382ebefb707d1e75ee608c27a2269b9799a333bf61a5dfd16ef1207a9 |
Hashes for topocalc-0.3.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1970a27ee01f76021cc88cb755f53ccb2a95454c09e398637695b8b8df6222ce |
|
MD5 | 2f70efaf0d12dae75e750aea4cb1e1b3 |
|
BLAKE2b-256 | 66f24899327a066fd9e2dbb69da2d9ff7d4e057f1f2384c3119f9a9d98d701d5 |
Hashes for topocalc-0.3.1-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8f0aaf15b7ee0e4c34d632bf8b14e50e79578d3210679758d872d0a19de1d50 |
|
MD5 | ba74afe133622e93aa5873c08d522572 |
|
BLAKE2b-256 | 302e508ccbf1c43c7feaacd49e1e3d3049c1c61e29ca48328fe5e9bae1c709e2 |
Hashes for topocalc-0.3.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb480379d5246940a0b618ab2ef55baa10ac322a40c01782eae923f789e7cca2 |
|
MD5 | 706ccb3189612d8e0ceca59aa06f95ea |
|
BLAKE2b-256 | 10c6694fead9b28dc2f314a321c38027bcfe832bf803dfc70e42ef3e644a9b7f |
Hashes for topocalc-0.3.1-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0380eafc83327aeee24b33c10c1d337052dc7aac78c4cb2d469846c180edf329 |
|
MD5 | 0e5818707d8bdb9c9852f9078688dc80 |
|
BLAKE2b-256 | 3b16adfeb568b3c5d7ea1933b605937f2b080a8fb3bdec686cbe005cb9fd1235 |