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
Backgourd
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 aspect uses the gradient 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.2.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd64f29eb83611b4d5d28364b0cc24d13df514d4a141231cde77d1755eaf0998 |
|
MD5 | 32523d02f866c0d19ed935ee559abbab |
|
BLAKE2b-256 | e8d82881116817b28659413bceb197803ddaf10ddc472961196943e88e7c209f |
Hashes for topocalc-0.2.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f1b9035d29e7af97a710ec79e7bee62ee1d05f70cfe9794086440ff80f78d70 |
|
MD5 | 074c03fc238acbcbd2876a10bdc72ba6 |
|
BLAKE2b-256 | 2d64dd94bdc3b40f4164da6698d87f276051dcf5c9abe78f018e3e7c469607f3 |
Hashes for topocalc-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2e7cdf02d42bd949fa87e74bc96408b9aca1c5763d6475161ef32ad3aa1e32e |
|
MD5 | c2bdbc3124f63ab5d21b976873949c49 |
|
BLAKE2b-256 | 46c68994f0c4e4317dcc3ca3c66859970d1373d601903e2a0173c7686650c70d |
Hashes for topocalc-0.2.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39b942f22f8e671931e977d162e169f565fd18e22747734a3313be20d175b3cd |
|
MD5 | f3e868a87d4d2a9aeba8e7e1d40512a6 |
|
BLAKE2b-256 | 69fd3b1edfe8e5970b2d732c2998a2e8fdb497c2d96ed3be159b8aa692558dca |
Hashes for topocalc-0.2.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83eccd740e00f0d07a0a63ecc124e695c2457fa8b575fa57dce81c94c33df017 |
|
MD5 | 738ad73a61825a850abab6bd54d5a169 |
|
BLAKE2b-256 | e9b10761e315a9bdbd45f2225632c2014ac0a8097639bb0e9fcd673e61ed7b85 |
Hashes for topocalc-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e81cdb9d8a43ce80cce9871f3b9d11145d1da3e3d82463b2767ea9745edf08a |
|
MD5 | b7029b9f85f883d47ff3b311eacecb96 |
|
BLAKE2b-256 | 067d4490a60f9e457c7c4aa711f570553ee92f2d716d2c7a75cab64df943e15d |
Hashes for topocalc-0.2.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6de606a62091391e272ebd17710ab64e90144d7d66a709130246fbe97e767f71 |
|
MD5 | ca820f9a32082d166a61f3cfc07c1638 |
|
BLAKE2b-256 | a9977683ba7df5e41b04e798b1460a4efd3f91516603aa2f139d472fc6ad3730 |
Hashes for topocalc-0.2.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 832bbbbeef69eb0163c43f0676af1b363962e1bdb3400641719c4e61f8918dcf |
|
MD5 | 324c4fc3bbfed50057cd3a234f20d39a |
|
BLAKE2b-256 | 363dfd8dd8856b84821db0940b3b36439fd8212c454777ea412c7eadc131eb05 |
Hashes for topocalc-0.2.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7be367b71042911c2646fd58aadbe10d60d1c443aca5f5d6933a63ee5d11bcf0 |
|
MD5 | 5f41a87846be451d787360c9a222e35a |
|
BLAKE2b-256 | 4fa6a7851ffb6f9a660409703d5e1ec2a31e82d7dd2711d46b0a9261db767534 |
Hashes for topocalc-0.2.0-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 545223bc44e5d4b193a99d9379df9a386479cf03ac2060490f58c974f262040b |
|
MD5 | 2bf324bd4bff1db3f4a5cb6dba8948f3 |
|
BLAKE2b-256 | d66510ca44bb35012caab461af7c124b3245ca0e9201d167dc768b640aaa3833 |
Hashes for topocalc-0.2.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4af551780ce195843ae40a0584c1a7dd9f12f79556194ba6f9399bdcc04e1073 |
|
MD5 | 334c2f1fbda884831acd528dfd6dabef |
|
BLAKE2b-256 | 67f693d9ffe9d813365e935641300ad8bcf3f2457374d95ccd5077151331ec10 |
Hashes for topocalc-0.2.0-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18dcc49b0b7a6bf6373037fa6c1b819a809a52a4a4c03ce401f25972cffe8602 |
|
MD5 | 8260ed6e2b41f10ca0ab1e41e42bbd5d |
|
BLAKE2b-256 | 5f2c04b029b9d64c69e43b86d7fc16f79c469610c09fb5c7605bc9d7fc1454f5 |