Calculate slope aspects on a RasterModelGrid
.
calc_slope_aspect_of_nodes_horn
(*args, **kwargs)[source]¶Calculate slope and aspect.
Note
This method is deprecated as of Landlab version 1.0.
Use grid.calc_slope_at_node()
instead.
Note
THIS CODE HAS ISSUES (SN 25-Sept-14): This code didn’t perform well on a NS facing elevation profile. Please check slope_aspect_routines_comparison.py under landlabexamples before using this. Suggested alternative: calculate_slope_aspect_at_nodes_burrough
Calculates the local topographic slope (i.e., the down-dip slope, and presented as positive), and the aspect (dip direction in radians clockwise from north), at the given nodes, ids. All ids must be of core nodes.
This method uses the Horn 1981 algorithm, the one employed by many GIS packages. It should be significantly faster than alternative slope methods.
If ids is not provided, the slope will be returned for all core nodes.
vals is either the name of an existing grid field from which to draw topographic data, or an array of values to use. If an array of values is passed, it must be nnodes long. If vals is not provided, this method will default to trying to use the field “topographic__elevation”.
Parameters: | grid : RasterModelGrid
ids : array_like of int, optional
vals : str or ndarray, optional
|
---|---|
Returns: | (slope, aspect) : tuple of float
|
Examples
>>> from landlab import RasterModelGrid
>>> import numpy as np
>>> grid = RasterModelGrid((4, 5))
Create a south-facing slope.
>>> elevation = np.array([
... 0., 0., 0., 0., 0,
... 1., 1., 1., 1., 1,
... 2., 2., 2., 2., 2,
... 3., 3., 3., 3., 3])
>>> (slope, aspect) = calc_slope_aspect_of_nodes_horn(grid,
... vals=elevation)
>>> len(slope) == grid.number_of_core_nodes
True
>>> len(aspect) == grid.number_of_core_nodes
True
>>> slope
array([ 1., 1., 1., 1., 1., 1.])
>>> aspect * 180. / np.pi
array([ 180., 180., 180., 180., 180., 180.])
Make the slope north-facing by multiplying elevations by -1. The slopes will still be positive but the aspects will change.
>>> elevation *= -1
>>> (slope, aspect) = calc_slope_aspect_of_nodes_horn(grid,
... vals=elevation)
>>> slope
array([ 1., 1., 1., 1., 1., 1.])
>>> aspect * 180. / np.pi
array([ 0., 0., 0., 0., 0., 0.])
Double the slope and make it west-facing.
>>> elevation = np.array([
... 0., 1., 2., 3., 4.,
... 0., 1., 2., 3., 4.,
... 0., 1., 2., 3., 4.,
... 0., 1., 2., 3., 4.])
>>> elevation *= 2.
>>> (slope, aspect) = calc_slope_aspect_of_nodes_horn(grid,
... vals=elevation)
>>> slope
array([ 2., 2., 2., 2., 2., 2.])
>>> aspect * 180. / np.pi
array([ 270., 270., 270., 270., 270., 270.])
Make the slope east-facing by multiplying elevations by -1. The slopes will still be positive but the aspects will change.
>>> elevation *= -1.
>>> (slope, aspect) = calc_slope_aspect_of_nodes_horn(grid,
... vals=elevation)
>>> slope
array([ 2., 2., 2., 2., 2., 2.])
>>> aspect * 180. / np.pi
array([ 90., 90., 90., 90., 90., 90.])
LLCATS: DEPR NINF SURF