knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(intercali)

Create transects

This function allows to create transects by reusing the make.design function of the dssd package. The make.design function allows to:
choose different types of survey design such as zigzag or parallel transects design
choose the desired transect length (approximately) line.transect
choose the angle of the transects design angle
choose the spacing between transects spacing
* and others : see ?make.design

In contrast to make.design, the create_transect function returns an sf object (data.frame) containing information about the different transects created.

Example

An example of this function use a region object created thanks to the package dssd.

From this region object, zigzag transects with a approximative length of 400000m are created in the study area. The function returns a sf dataframe.

library(sf)
library(dssd)
library(dsims)

# Use of the St Andrews bay map from the dssd package
shapefile.name <- system.file("extdata", "StAndrew.shp", package = "dssd")

# Creation of the object with the make.region function of the dsims package
region <- make.region(region.name = "St Andrews bay",
                      shape = shapefile.name,
                      units = "m")

transects <- create_transect(region_obj = region,
                             crs = 2154,
                             design = "eszigzag",
                             line.length = 400000,
                             design.angle = 30,
                             truncation = 400)

head(transects)

transects %>%
  st_length() %>%
  sum()

Crop transects

This function allows to resize the transects transect_obj created with the create_transect function, in order to perfectly fit the density map use to simulate individuals map_obj.

This is an improvement that should come later to have a grid that matches perfectly with the study region region_obj or density_obj. For the moment, the grid created with extract_map does not perfectly match the total area of the region because it only keeps squares of the same size, so the edges of the study region are slightly cropped. With the create_transect function, the transects are created on the basis of the total region region_obj and not on the basis of the grid map_obj. Hence the need to resize with the fonction crop_transect.

Example

In this example we use the datasets dataset_map and dataset_transects integrated in the intercali package.

data(dataset_transects)
data(dataset_map)

# The transects do not correspond perfectly to the density map
plot_transects(transect_obj = dataset_transects, 
               map_obj = dataset_map, 
               crs = 2154)

# Crop transects
cropped_transects <- crop_transect(transect_obj = dataset_transects,
                                   map_obj = dataset_map)

# The transects correspond perfectly to the density map
plot_transects(transect_obj = cropped_transects, 
               map_obj = dataset_map, 
               crs = 2154)

Segmentize transects

This function allows you to segment the transects. From the created transect object transect_obj and by choosing the desired length in m length_m for the segments, the function returns a new table with the segments cut and named according to the transect and the segment, for example, Sample.Label: 1-2 indicating the segment 2 of transect 1.

The function is not mine it was found here

Example

In this example we use the datasets dataset_transects integrated in the intercali package comming from the create_transect function. In this example, the length of the segments length_m is chosen at 2000m.

data("dataset_transects")

segs <- segmentize_transect(transect_obj = dataset_transects,
                            length_m = 2000,
                            to = "LINESTRING")

head(segs)

Get monitored area

The get_monitored_area function is used to calculate the area of the study area that is monitored by the transects. The maximum distance monitored truncation_m on the transects is used to calculate the area of the study area map_obj truly followed by the transects transect_obj.

Example

In this example we use the datasets dataset_map and dataset_transects integrated in the intercali package. In this example, the maximum distance at which an individual can be observed truncation_m is chosen at 400m.

data("dataset_map")
data("dataset_segs")

get_monitored_area(transect_obj = dataset_segs,
                   map_obj = dataset_map,
                   truncation_m = 400)

Plot transects

This function allows to plot the created transects transect_obj on the study area map_obj.map_obj must be a sf data.frame. If the transects are cut in multiple segments, the ifsegs argument allows to highlight with different colors the differents segment of the transect.

Example

Examples of this function use a zigzag transects dataset_transect created in the study area thanks to the create_transect function or segmentize transects dataset_segs created with the segmentize_transects function. Then the transects are represented in the study area map_obj (created with create_map) or in the region object region thanks to the plot_transect function.

library(dssd)
library(dsims)
data(dataset_transects)
data(dataset_segs)
data(dataset_map)


# Use of the St Andrews bay map from the dssd package
shapefile.name <- system.file("extdata", "StAndrew.shp", package = "dssd")

# Creation of the object with the make.region function of the dsims package
region <- make.region(region.name = "St Andrews bay",
                      shape = shapefile.name,
                      units = "m")

# Plot transects
plot_transects(transect_obj = dataset_transects, 
               map_obj = region, 
               crs = 2154)

# Vizualize segment
plot_transects(transect_obj = dataset_segs, 
               map_obj = dataset_map, 
               crs = 2154,
               ifsegs = TRUE)


maudqueroue/intercali documentation built on Oct. 8, 2022, 2:09 p.m.