direction {terra} | R Documentation |
Direction
Description
The direction (azimuth) to or from the nearest cell that is not NA
. The direction is expressed in radians, unless you use argument degrees=TRUE
.
Usage
## S4 method for signature 'SpatRaster'
direction(x, from=FALSE, degrees=FALSE, method="cosine", filename="", ...)
Arguments
x |
SpatRaster |
from |
Logical. Default is |
degrees |
Logical. If |
method |
character. Should be "geo", or "cosine". With "geo" the most precise but slower geodesic method of Karney (2003) is used. The "cosine" method is faster but less precise |
filename |
Character. Output filename (optional) |
... |
Additional arguments as for |
Value
SpatRaster
See Also
Examples
r <- rast(ncol=36,nrow=18, crs="+proj=merc")
values(r) <- NA
r[306] <- 1
b <- direction(r, degrees=TRUE)
plot(b)
crs(r) <- "+proj=longlat"
b <- direction(r)
plot(b)
[Package terra version 1.8-60 Index]