Learn R Programming

spatialEco (version 2.0-2)

sampleTransect: Sample transect

Description

Creates random transects from points and generates sample points along each transect

Usage

sampleTransect(
  x,
  min.dist,
  max.dist,
  distance = NULL,
  azimuth = NULL,
  id = NULL,
  ...
)

Value

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.

Arguments

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

Author

Jeffrey S. Evans <jeffrey_evans@tnc.org>

Details

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.

Examples

Run this code
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")
}

Run the code above in your browser using DataLab