geotrellis.raster.mapalgebra.focal.Aspect.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geotrellis-raster_2.11 Show documentation
Show all versions of geotrellis-raster_2.11 Show documentation
GeoTrellis is an open source geographic data processing engine for high performance applications.
The newest version!
package geotrellis.raster.mapalgebra.focal
import geotrellis.raster._
import geotrellis.raster.mapalgebra.focal.hillshade.{SurfacePoint, SurfacePointCalculation}
import geotrellis.raster.mapalgebra.focal.Angles._
/** Calculates the aspect of each cell in a raster.
*
* Aspect is the direction component of a gradient vector. It is the
* direction in degrees of which direction the maximum change in direction is pointing.
* It is defined as the directional component of the gradient vector and is the
* direction of maximum gradient of the surface at a given point. It uses Horn's method
* for computing aspect.
*
* As with slope, aspect is calculated from estimates of the partial derivatives dz / dx and dz / dy.
*
* If Aspect operations encounters NoData in its neighborhood, that neighborhood cell well be treated as having
* the same elevation as the focal cell.
*
* Aspect is computed in degrees from due north, i.e. as an azimuth in degrees not radians.
* The expression for aspect is:
* {{{
* val aspect = 270 - 360 / (2 * Pi) * atan2(`dz / dy`, - `dz / dx`)
* }}}
*
*/
object Aspect {
def apply(tile: Tile, n: Neighborhood, bounds: Option[GridBounds], cs: CellSize): Tile = {
new SurfacePointCalculation[Tile](tile, n, bounds, cs)
with DoubleArrayTileResult
{
def setValue(x: Int, y: Int, s: SurfacePoint) {
resultTile.setDouble(x, y, degrees(s.aspect))
}
}
}.execute()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy