swath_profile {geoprofiler} | R Documentation |
Swath Elevation Profile Statistics
Description
Calculate swath-profile values perpendicular to a straight baseline.
The distance between samples and the number of samples can be
specified, see arguments k
and dist
. Values of the swath-profile are
extracted from a given raster file, see argument raster
. CRS of raster
and points have to be the same.
Usage
swath_profile(
profile,
raster,
k = 1,
dist,
crs = terra::crs(raster),
method = c("bilinear", "simple")
)
Arguments
profile |
either a
|
raster |
Raster file ( |
k |
integer. number of lines on each side of the baseline |
dist |
numeric. distance between lines |
crs |
character. coordinate reference system. Both the |
method |
character. method for extraction of raw data, see
|
Details
The final width of the swath is: 2k \times \text{dist}
.
Value
list.
swath
matrix. Statistics of the raster measured along the lines
data
list of numeric vector containing the data extracted from the raster along each line
lines
swath lines as
"sf"
objects
Source
The algorithm is a modified version of "swathR" by Vincent Haburaj (https://github.com/jjvhab/swathR).
See Also
Examples
# Create a random raster
r <- terra::rast(ncol = 10, nrow = 10, xmin = -150, xmax = -80, ymin = 20, ymax = 60, crs = "WGS84")
terra::values(r) <- runif(terra::ncell(r))
# Create a random profile
profile <- data.frame(lon = c(-140, -90), lat = c(55, 25)) |>
sf::st_as_sf(coords = c("lon", "lat"), crs = "WGS84")
swath_profile(profile, r, k = 2, dist = 1)