swath_profile | R Documentation |
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.
swath_profile(
profile,
raster,
k = 1,
dist,
crs = terra::crs(raster),
method = c("bilinear", "simple")
)
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
|
The final width of the swath is: 2k \times \text{dist}
.
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
The algorithm is a modified version of "swathR" by Vincent Haburaj (https://github.com/jjvhab/swathR).
swath_stats()
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.