View source: R/sampleTransect.R
sampleTransect | R Documentation |
Creates random transects from points and generates sample points along each transect
sampleTransect(
x,
min.dist,
max.dist,
distance = NULL,
azimuth = NULL,
id = NULL,
...
)
x |
A sf point object |
min.dist |
Minimum length of transect(s) |
max.dist |
Maximum length of transect(s) |
distance |
A vector of distances, same length as x, used to define transect distances (length) |
azimuth |
A vector of azimuths, same length as x, used to define transect direction |
id |
A unique identification column in x |
... |
Additional arguments passed to st_sample |
Function create lines and samples using random or defined direction and length transects and then creates a point sample along each transect. The characteristic of the sample points are defined by arguments passed to the sf::st_sample function. The distance and azimuth arguments allow for specifying the exact length and direction for each points transect.
A list object contaning sf LINES and POINTS objects representing random transects and sample points along each transect. The "ID" column links the resulting data.
Jeffrey S. Evans <jeffrey_evans@tnc.org>
if(require(sp, quietly = TRUE)) {
library(sf)
data(meuse, package = "sp")
meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992,
agr = "constant")
meuse <- meuse[sample(1:nrow(meuse),10),]
transects <- sampleTransect(meuse, min.dist=200, max.dist=500,
type="regular", size=20)
plot(st_geometry(transects$transects))
plot(st_geometry(meuse), pch=19, cex=2, add=TRUE)
plot(st_geometry(transects$samples),
col="red", pch=19, add=TRUE)
} else {
cat("Please install sp package to run example", "\n")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.