raster_pres: Create a presence raster

Description Usage Arguments Details Examples

View source: R/s4_grids.R

Description

Converts a raster of counts to a raster of presence-only or presence-absence

Usage

1

Arguments

r

A raster

Details

This function sets any values >= 1 to 1. If the background values of the raster are NA, they remain NA in the output, allowing the raster to be interpreted as presence-only. If the background values of the raster are 0, then the result will be also contain 0s, allowing the raster to be interpreted as presence-abscence.

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#Load example data
data(acoustic)

#Process detections
proc.det <- proc_dets(det = acoustic$detections, sta = acoustic$stations)

#Create COAs
coas.60 <- coa_locs(proc.det)

#Initialize a base raster
r.sa <- init_raster(study_area = acoustic$study_area, res = 0.005)

#Rasterize COAs
coa.r <- rasterize_dets(det_locs = coas.60, r = r.sa)

#Presence-only layer for all animals in the dataset
coa.pres <- raster_pres(coa.r)
#Plot
plot(coa.pres)

##Use tidy workflow to create presence for multiple individuals

library(dplyr)

#Animal 1
ani1 <- coas.60 %>%
filter(id == unique(id)[1]) %>%
rasterize_dets(r.sa) %>%
raster_pres()

#Animal 2
ani2 <- coas.60 %>%
filter(id == unique(id)[2]) %>%
rasterize_dets(r.sa) %>%
raster_pres()

#Animal 3
ani3 <- coas.60 %>%
filter(id==unique(id)[3]) %>%
rasterize_dets(r.sa) %>%
raster_pres()

#Animal 4
ani4 <- coas.60 %>%
filter(id==unique(id)[4]) %>%
rasterize_dets(r.sa) %>%
raster_pres()

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