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 sf object or a matrix(ncol=2, nrow=2) with x and y coordinates of beginning and end point of the baseline; each point in one row

column 1

x coordinates (or longitudes)

column 2

y coordinates (latitudes)

raster

Raster file ("SpatRaster" object as loaded by terra::rast())

k

integer. number of lines on each side of the baseline

dist

numeric. distance between lines

crs

character. coordinate reference system. Both the raster and the profile are transformed into this CRS. Uses the CRS of raster by default.

method

character. method for extraction of raw data, see terra::extract(): default value: "bilinear"

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

swath_stats()

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)

[Package geoprofiler version 0.0.2 Index]