plotSpatialCov: Plot observations on raster image

View source: R/plotSpatialCov.R

plotSpatialCovR Documentation

Plot observations on raster image

Description

Plot tracking data over a raster layer.

Usage

plotSpatialCov(
  data,
  spatialCov,
  segments = TRUE,
  compact = TRUE,
  col = NULL,
  alpha = 1,
  size = 1,
  shape = 16,
  states = NULL,
  animals = NULL,
  ask = TRUE,
  return = FALSE,
  stateNames = NULL
)

Arguments

data

Data frame or momentuHMMData object, with necessary fields 'x' (longitudinal direction) and 'y' (latitudinal direction). A momentuHMM, miHMM, or miSum object is also permitted, from which the data will be extracted. If states=NULL and a momentuHMM, miHMM, or miSum object is provided, the decoded states are automatically plotted.

spatialCov

raster object of the RasterLayer class on which to plot the location data

segments

TRUE if segments should be plotted between the observations (default), FALSE otherwise.

compact

FALSE if tracks should be plotted separately, TRUE otherwise (default).

col

Palette of colours to use for the dots and segments. If not specified, uses default palette.

alpha

Transparency argument for geom_point.

size

Size argument for geom_point.

shape

Shape argument for geom_point. If states is provided, then shape must either be a scalar or a vector of length length(unique(states)). If states=NULL, then shape must either be a scalar or a vector consisting of a value for each individual to be plotted.

states

A sequence of integers, corresponding to the decoded states for these data. If specified, the observations are colored by states.

animals

Vector of indices or IDs of animals/tracks to be plotted. Default: NULL; all animals are plotted.

ask

If TRUE, the execution pauses between each plot.

return

If TRUE, the function returns a ggplot object (which can be edited and plotted manually). If FALSE, the function automatically plots the map (default).

stateNames

Optional character vector of length max(states) indicating state names. Ignored unless states is provided.

Examples

## Not run: 
stepDist <- "gamma"
angleDist <- "vm"

# plot simulated data over forest raster automatically loaded with the packge
spatialCov<-list(forest=forest)
data <- simData(nbAnimals=2,nbStates=2,dist=list(step=stepDist,angle=angleDist),
                Par=list(step=c(100,1000,50,100),angle=c(0,0,0.1,5)),
                beta=matrix(c(5,-10,-25,50),nrow=2,ncol=2,byrow=TRUE),
                formula=~forest,spatialCovs=spatialCov,
                obsPerAnimal=225,states=TRUE)

plotSpatialCov(data,forest,states=data$states)

## End(Not run)

momentuHMM documentation built on Oct. 19, 2022, 1:07 a.m.