# Note that for CRAN testing purposes all files written in example code must
# be written to a temporary directory, to view this location type tempdir().
# It is however advised that you replace the tempdir() commands in the code
# below to a more easily accessible directory to which the files will be
# written.
# Make the default design in the default study area
design <- make.design()
transects <- generate.transects(design)
write.transects(transects, dsn = paste0(tempdir(), "/", "transects.shp"))
# Writing csv file example
write.transects(transects, dsn = paste0(tempdir(), "/", "transects.csv"))
# Writing txt file example
write.transects(transects, dsn = paste0(tempdir(), "/", "transects.txt"))
# Writing gpx file example - must project transect coords into lat/lon
#Load the unprojected shapefile
shapefile.name <- system.file("extdata", "TentsmuirUnproj.shp", package = "dssd")
sf.shape <- sf::read_sf(shapefile.name)
# Check current coordinate reference system
orig.crs <- sf::st_crs(sf.shape)
# Define a European Albers Equal Area projection
proj4string <- "+proj=aea +lat_1=56 +lat_2=62 +lat_0=50 +lon_0=-3 +x_0=0
+y_0=0 +ellps=intl +units=m"
# Project the study area on to a flat plane
projected.shape <- sf::st_transform(sf.shape, crs = proj4string)
# Create the survey region in dssd
region.tm <- make.region(region.name = "Tentsmuir",
strata.name = c("Main Area", "Morton Lochs"),
shape = projected.shape)
design <- make.design(region = region.tm,
transect.type = "line",
design = "systematic",
samplers = 20,
design.angle = 90)
survey <- generate.transects(design)
plot(region.tm, survey)
write.transects(survey,
dsn = paste0(tempdir(), "/", "transects.gpx"),
layer = "lines",
dataset.options = "GPX_USE_EXTENSIONS=yes",
proj4string = orig.crs)
Run the code above in your browser using DataLab