Skip to contents

Statistics of the elevation data across a swath profile.

Usage

swath_stats(x, profile.length = NULL)

Arguments

x

list. The return object of swath_profile()

profile.length

numeric or units object. If NULL the fractional distance is returned, i.e. 0 at start and 1 at the end of the profile.

Value

tibble

See also

Examples

# Create a random raster
r <- terra::rast(ncol = 10, nrow = 10, xmin = -150, xmax = -80, ymin = 20, ymax = 60)
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 <- swath_profile(profile, r, k = 5, dist = 10)
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Warning: no non-missing arguments to max; returning -Inf
#> Warning: no non-missing arguments to max; returning -Inf

swath_stats(swath, profile.length = profile_length(profile_line(profile)))
#> # A tibble: 16 × 9
#>    distance elevation   min quantile25 median quantile75   max  mean     sd
#>         [m]     <dbl> <dbl>      <dbl>  <dbl>      <dbl> <dbl> <dbl>  <dbl>
#>  1       0      0.817 0.257      0.257  0.257      0.257 0.817 0.417 0.253 
#>  2  349377.     0.718 0.381      0.381  0.487      0.655 0.792 0.575 0.164 
#>  3  698755.     0.416 0.332      0.353  0.416      0.624 0.893 0.566 0.223 
#>  4 1048132.     0.430 0.408      0.413  0.430      0.519 0.674 0.508 0.107 
#>  5 1397509.     0.723 0.368      0.368  0.435      0.558 0.723 0.518 0.137 
#>  6 1746887.     0.746 0.299      0.299  0.481      0.705 0.910 0.590 0.239 
#>  7 2096264.     0.684 0.452      0.452  0.464      0.522 0.684 0.528 0.0910
#>  8 2445641.     0.676 0.382      0.416  0.517      0.581 0.676 0.535 0.108 
#>  9 2795018.     0.287 0.287      0.349  0.536      0.573 0.637 0.502 0.133 
#> 10 3144396.     0.770 0.497      0.505  0.530      0.602 0.832 0.614 0.133 
#> 11 3493773.     0.722 0.254      0.300  0.439      0.574 0.722 0.490 0.172 
#> 12 3843150.     0.495 0.313      0.322  0.350      0.496 0.735 0.461 0.156 
#> 13 4192528.     0.487 0.274      0.274  0.381      0.585 0.697 0.484 0.178 
#> 14 4541905.     0.370 0.363      0.363  0.363      0.369 0.702 0.449 0.146 
#> 15 4891282.     0.482 0.482      0.482  0.482      0.482 0.712 0.548 0.104 
#> 16 5240660.     0.502 0.502      0.502  0.502      0.502 0.502 0.502 0