Topography¶
- class Topography(dem, cellsize, diff=<function diff_finite>, indexing='xy', transform=None, crs=None, **kwargs)[source]¶
Bases:
objectCalculates various topographic indices at each pixel from on a given DEM.
- Parameters:
dem (
ndarray) – DEM, i.e. z coordinates of each pixelcellsize (
tuple) – Size of a pixel given as pair(width, height)diff (
callable) – differentiation function. Eitherdiff_finite(), ordiff_gauss()indexing (
str) – eitherxyorij, same meaning as fornumpy.meshgridtransform (
Optional[list]) – list of 6 numbers that describe the transformation. Only used forlatitude,rad_angle, andsun_exposure.crs (
Optional[str]) – Name of the coordinate system. Only used forlatitude,rad_angle, andsun_exposure.kwargs – keyword arguments for
diff. Usuallysigma=VALUEfor the gaussian derivative
Note that the DEM is assumed to live on a regular rectangular grid.
Note that the object caches some of the calculated quantities for reuse. In order to free memory you should let go of the
Topographyinstance after calculation of the quantities in which you are interestedMethods Summary
D1x()Calculate the first derivative (slope) of the DEM in X direction.
D1y()Calculate the first derivative (slope) of the DEM in Y direction.
D2x()Calculate the 2nd derivative (curvature) of the DEM in X direction.
D2y()Calculate the 2nd derivative (curvature) of the DEM in Y direction.
Dx2()Return the square of the X slope.
Dy2()Return the square of the Y slope.
aspect()Returns the angle of the gradient direction in radians counted from north in clockwise direction.
Returns the absolute value of the total curvature.
Calculate the 2nd derivative (curvature) of the DEM in X direction.
Calculate the 2nd derivative (curvature) of the DEM in Y direction.
diff(dx, dy)Differentiate the DEM
dxtimes in X direction anddytimes in Y direction.eastness()Calculate the eastness, i.e. the sine-transformed aspect.
grad_dir()Returns the angle of the gradient direction in radians counted from east in counter-clockwise direction (i.e.
latitude()Get the latitude in radians at each pixel.
Calculate the northness, i.e. the cosine-transformed aspect.
Calculate the planform curvature, i.e. the curvature of the terrain surface in the horizontal plane.
Calculate the profile curvature., i.e. the curvature of a terrain cross-section on a vertical plane containing the gradient vector.
rad_angle([declination])Return the cosine of the "radiation angle" according to Herbsta, et al 2006 [1].
slope()Returns the absolute value of the total slope.
Returns the slope angle, i.e. the angle between the horizontal plane and the gradient vector.
Returns the x slope angle, i.e. the angle between the x axis and the surface in the xz plane.
Returns the y slope angle, i.e. the angle between the y axis and the surface in the yz plane.
slope_x()Calculate the first derivative (slope) of the DEM in X direction.
slope_y()Calculate the first derivative (slope) of the DEM in Y direction.
sun_exposure([declination])Return the cosine of the angle between surface normal and the sun at midday.
Calculate the tangential curvature, i.e. the curvature of a terrain cross-section on a vertical plane perpendicular to the gradient direction.
Sine of the slope angle.
Sine of the x slope angle.
Sine of the y slope angle.
Methods Documentation
- D1x()[source]¶
Calculate the first derivative (slope) of the DEM in X direction. Same as
self.diff(1, 0).- Return type:
- D1y()[source]¶
Calculate the first derivative (slope) of the DEM in Y direction. Same as
self.diff(0, 1).- Return type:
- D2x()[source]¶
Calculate the 2nd derivative (curvature) of the DEM in X direction. Same as
self.diff(2, 0).- Return type:
- D2y()[source]¶
Calculate the 2nd derivative (curvature) of the DEM in Y direction. Same as
self.diff(0, 2).- Return type:
- aspect()[source]¶
Returns the angle of the gradient direction in radians counted from north in clockwise direction.
- Return type:
- curvature()[source]¶
Returns the absolute value of the total curvature. Same as
sqrt(D2x**2 + D2y**2).- Return type:
- curvature_x()¶
Calculate the 2nd derivative (curvature) of the DEM in X direction. Same as
self.diff(2, 0).- Return type:
- curvature_y()¶
Calculate the 2nd derivative (curvature) of the DEM in Y direction. Same as
self.diff(0, 2).- Return type:
- diff(dx, dy)[source]¶
Differentiate the DEM
dxtimes in X direction anddytimes in Y direction.- Return type:
- eastness()[source]¶
Calculate the eastness, i.e. the sine-transformed aspect.
This quantity can be understood as the projected length of the gradient direction on the east axis in the horizontal plane.
- Return type:
- grad_dir()[source]¶
Returns the angle of the gradient direction in radians counted from east in counter-clockwise direction (i.e. mathematical convention).
- Return type:
- northness()[source]¶
Calculate the northness, i.e. the cosine-transformed aspect.
This quantity can be understood as the projected length of the gradient direction on the north axis in the horizontal plane.
- Return type:
- plan_curvature()[source]¶
Calculate the planform curvature, i.e. the curvature of the terrain surface in the horizontal plane.
See: - http://surferhelp.goldensoftware.com/gridops/plan_curvature.htm - Map Use: Reading, Analysis, Interpretation, Seventh Edition (p. 360)
- Return type:
- prof_curvature()[source]¶
Calculate the profile curvature., i.e. the curvature of a terrain cross-section on a vertical plane containing the gradient vector.
See: - http://surferhelp.goldensoftware.com/gridops/profile_curvature.htm - Map Use: Reading, Analysis, Interpretation, Seventh Edition (p. 360)
- Return type:
- rad_angle(declination=0)[source]¶
Return the cosine of the “radiation angle” according to Herbsta, et al 2006 [1].
- Parameters:
declination – sun declination angle in radians. Can be used to adjust for seasonal changes.
All input arguments must be of the same shape or scalars.
The formulate is taken from Herbsta, et al. 2006 [1] who cite Moore, et al. 1988 [2] as source - which doesn’t mention the formula anywhere.
[1] (2006 Geostatistical co-regionalization of soil hydraulic properties in a microscale catchment using terrain attributes [Herbsta, et al.])
[2] Moore, I.D., Burch, G.J., Mackenzie, D.H., 1988. Topographic effects on the distribution of surface soil water and the location of ephemeral gullies. American Society of Agricultural Engi- neers 31 (4), 1098 – 1107.
- Return type:
- slope()[source]¶
Returns the absolute value of the total slope. Same as
sqrt(D1x**2 + D1y**2).- Return type:
- slope_angle()[source]¶
Returns the slope angle, i.e. the angle between the horizontal plane and the gradient vector. This is a non-negative value.
- Return type:
- slope_angle_x()[source]¶
Returns the x slope angle, i.e. the angle between the x axis and the surface in the xz plane.
- Return type:
- slope_angle_y()[source]¶
Returns the y slope angle, i.e. the angle between the y axis and the surface in the yz plane.
- Return type:
- slope_x()¶
Calculate the first derivative (slope) of the DEM in X direction. Same as
self.diff(1, 0).- Return type:
- slope_y()¶
Calculate the first derivative (slope) of the DEM in Y direction. Same as
self.diff(0, 1).- Return type:
- sun_exposure(declination=0)[source]¶
Return the cosine of the angle between surface normal and the sun at midday.
- Parameters:
declination – sun declination angle in radians. Can be used to adjust for season. A positive value corresponds to a northward deviation. Zero means the sun is in the zenith over the equator.
This is very similar to
rad_anglebut not exactly the same.- Return type:
- tang_curvature()[source]¶
Calculate the tangential curvature, i.e. the curvature of a terrain cross-section on a vertical plane perpendicular to the gradient direction.
See: - http://surferhelp.goldensoftware.com/gridops/tangential_curvature.htm - Map Use: Reading, Analysis, Interpretation, Seventh Edition (p. 360)
- Return type: