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.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d06d083ce9b848df04b39d1b2bb433f6a0f9d40ab9b542df3535f045331255bf |
|
MD5 | 6dd8fa28e14be29b0667b1a6b26aff47 |
|
BLAKE2b-256 | 77bdc18e3a4e88e3c93061676dbddd70d752179df6c2f2dcdb4f03fa70807547 |
Hashes for topocalc-0.3.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c52432716d538c64c6b804b176fab4aa486393d272058b20286b4cf69d817f44 |
|
MD5 | 2d5bda089187eac6a5ba198d15c9c730 |
|
BLAKE2b-256 | 17d33fc601c6d482378788f61a825ebc9b11d3d5014040b26f65dc2db25cb69a |
Hashes for topocalc-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0fdaef1ace7e985efd14f8e923a501b021f196260523fb813e83d0c8f1076e5 |
|
MD5 | 7e1f43001634ae09d81fb3f086239893 |
|
BLAKE2b-256 | 34179b63959942cdeb4b81c9901cb35cf7ba86281be1bb8a5515c3a4b613a73c |
Hashes for topocalc-0.3.2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16dc1075f46592ec3d97057a34858cda54d0b4fc7e3563e0fddf49905c40d8dc |
|
MD5 | 4084307112ee53b986e93041f10fd7d4 |
|
BLAKE2b-256 | 19c1cd471f02f99b391619a8bc17f852f34a6b5cf182ecd2ee490d010dd7513c |
Hashes for topocalc-0.3.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3bc70c40ffe7a00965c460b62d408524d9e4fe339af556677dfb25b4cc14b33 |
|
MD5 | ab58d289446a85ff7f4ffee4c2b201ce |
|
BLAKE2b-256 | 9ac94a7359dfcf11552256239ca61318bb08b821f46b4ab84eb61b54c25bdd39 |
Hashes for topocalc-0.3.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3e66ff9131962048ac80ae8f00428462b5f9139c13d05754f72907091aea204 |
|
MD5 | 8026f582112698bf0f889e52692f899a |
|
BLAKE2b-256 | 5122e772b704f50569c914a12d54b94eb5ca91453779d1972b6f5a14b209833c |
Hashes for topocalc-0.3.2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c23138a28a70c626f8a6413ac6501dbf7ac4e7740f5702accb2cea51688c0595 |
|
MD5 | 01b7e1c391f6d4768565dbf4919b4b10 |
|
BLAKE2b-256 | cab0bfc1404845e94d12f19ca8b247614ac8a924dc059cfd8606615021fe812d |
Hashes for topocalc-0.3.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3f854dc4da40d08e4eafb7e6d9fdab448f5f16ca97c5f2e5df84516c8f44f93 |
|
MD5 | 8c94f0faa7cc7776091735b149f62e92 |
|
BLAKE2b-256 | 4639c445311991ec93603235106e4ac927f41bfa549d8794e0a09b86dded6ac7 |
Hashes for topocalc-0.3.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d47d990c7f34341488024b065373083ffed8faa505655ea7364b8100ae6e8d15 |
|
MD5 | dc420214a5c4b03adc87f715ff936e9e |
|
BLAKE2b-256 | f2e96b9e8dca1068a804b5ea403789939dbbd66a7c83e803c663854a2e93b6ca |
Hashes for topocalc-0.3.2-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7e3a9300359143b7a53ece02cfad474a8603043d7c0b16f26cc2bb3ea245d0a |
|
MD5 | ab933604cfd53b6a8e9a28d8ca2f6b2c |
|
BLAKE2b-256 | 30ca83468562b2a6047f7cc1ac62586d0acabfe713ebeb797f4a8e8119a3ec51 |
Hashes for topocalc-0.3.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59324aaa4ce88148ae5a35ea3096252b82582e72918455c60d44466ddf672d7b |
|
MD5 | 17f583255dfbed21703a04b1e99f04cd |
|
BLAKE2b-256 | 85ccdd610207b51513af88e54af13aaa93e894fb39793cf21e82c1bcff735d5f |
Hashes for topocalc-0.3.2-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d37a85e05f8ad76ed0b5f1555da970f9643ebc9be05d4287d0e55fb968b7de66 |
|
MD5 | 49fec1be8fa43ba6922482ab30028cd9 |
|
BLAKE2b-256 | 6b7bd66e9e0b512aa6da438fa556644760e8672c74cff458f62fd8cc48daa407 |