init_raster: Creates an empty raster for detection summaries

Description Usage Arguments Details Value Examples

View source: R/s4_grids.R

Description

This function can take one of user-defined x- and y-limits, station locations, or a study area polygon and create an empty raster to use in the detection summary figures.

Usage

1
2
3
init_raster(xlim = NULL, ylim = NULL, sta = NULL,
                   study_area = NULL, res = 0.01,
                   crs = sp::CRS("+init=epsg:4326"))

Arguments

xlim

A numeric vector of length 2 giving user-defined x-limits. If xlim is provided, ylim must also be provided. These fields override both sta and study_area.

ylim

A numeric vector of length 2 giving user-defined y-limits. If xlim is provided, ylim must also be provided. These fields override both sta and study_area.

sta

A data.frame with x- and y-coordinates of all the stations in the study area. The x- and y-coordinates should be in columns named "x" and "y", respectively. Ignored if xlim or ylim are provided. This field overrides study_area.

study_area

A polygon of class sfc from the package sf that delimits the study area.

res

A numeric vector of length 1 or 2 giving the size of a grid cell in units of the coordinate reference system. See res for details.

crs

A character or object of class CRS. Defines the coordinate reference system to use for the resulting raster. Should match the CRS of the input if applicable. Used by raster as the crs argument. Defaults to (CRS("+init=epsg:4326")), indicating EPSG code 4326 for WGS 84 lat/long.

Details

Behavior depends upon the input. Once the function reaches a valid input, it returns the raster without bothering to check if additional inputs were provided.

The order it checks in is:

  1. xlim and ylim (must provide both)

  2. sta (x- and y-coordinates should be named "x" and "y")

  3. study_area (polygon of class sfc)

Value

Returns an object of class RasterLayer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Load sample data
data(acoustic)

#Using xlim and ylim
xlim <- c(-64.628, -64.612)
ylim <- c(17.770, 17.795)
r.lim <- init_raster(xlim = xlim, ylim = ylim)

#Use UTM
xlim <- c(321160, 335010)
ylim <- c(1965700, 1973810)
r.lim.utm <- init_raster(xlim = xlim, ylim = ylim,
                         res = 500, #units here are meters
                         crs = sp::CRS("+init=epsg:32620"))

#Using sta
r.sta <- init_raster(sta = acoustic$stations)

#Using study_area
r.sa <- init_raster(study_area = acoustic$study_area)

#Change the resolution (in CRS units)
r.sa2 <- init_raster(study_area = acoustic$study_area,
                     res = 0.0001)

bsmity13/ADePTR documentation built on Nov. 9, 2019, 12:43 a.m.