Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

transitionLayer

Calculate Transition Layer


Description

Using a previously imported shape file that has been converted to a raster (see loadShape), Prepares a TransitionLayer object to be used in distance estimations (see distancesMatrix). Adapted from Grant Adams' script "distance to closest mpa".

Usage

transitionLayer(x, directions = c(16, 8, 4))

Arguments

x

A water raster; for example the output of loadShape

directions

The number of directions considered for every movement situation during cost calculation. See the vignettes for more details.

Details

It is highly recommended to read the vignette regarding distances matrix before running this function. You can find it by running vignette('a-2_distances_matrix', 'actel') or browseVignettes('actel')

Value

A TransitionLayer object.

Examples

# check if R can run the distance functions
aux <- c(
  length(suppressWarnings(packageDescription("raster"))),
  length(suppressWarnings(packageDescription("gdistance"))),
  length(suppressWarnings(packageDescription("sp"))),
  length(suppressWarnings(packageDescription("tools"))),
  length(suppressWarnings(packageDescription("rgdal"))))
missing.packages <- sapply(aux, function(x) x == 1)

if (any(missing.packages)) {
  message("Sorry, this function requires packages '",
    paste(c("raster", "gdistance", "sp", "tools", "rgdal")[missing.packages], collapse = "', '"),
    "' to operate. Please install ", ifelse(sum(missing.packages) > 1, "them", "it"),
    " before proceeding.")
} else {
  if (suppressWarnings(require("rgdal"))) {
    # Fetch actel's example shapefile location
    aux <- system.file(package = "actel")[1]

    # import the shape file
    x <- loadShape(path = aux, shape = "example_shapefile.shp", size = 20)

    # Build the transition layer
    t.layer <- transitionLayer(x)

    # inspect the output
    t.layer

  } else {
    message("Sorry, it appears that rgdal is not being able to load.")
  }
}
rm(aux, missing.packages)

actel

Acoustic Telemetry Data Analysis

v1.2.1
GPL-3
Authors
Hugo Flávio [aut, cre] (<https://orcid.org/0000-0002-5174-1197>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.