res_sk_map: Local Reserve Map With Seasonal Kendall Results

Description Usage Arguments Details Value Author(s) Examples

View source: R/res_sk_map.R

Description

Create a stylized reserve-level map of seasonal kendall results for use with the reserve level reporting template

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
res_sk_map(
  nerr_site_id,
  stations,
  sk_result = NULL,
  bbox,
  shp,
  station_labs = TRUE,
  lab_loc = NULL,
  bg_map = NULL,
  zoom = NULL,
  maptype = "toner-lite"
)

Arguments

nerr_site_id

chr string of the reserve to make, first three characters used by NERRS

stations

chr string of the reserve stations to include in the map

sk_result

vector of values denoting direction and significance of seasonal kendall results. Result should be c('inc', 'dec', 'insig', 'insuff') for significant positive, significant negative, no significant results, and insufficient data to calculate result.

bbox

a bounding box associated with the reserve. Should be in the format of c(xmin, ymin, xmax, ymax).

shp

sf data frame (preferred) or SpatialPolygons object

station_labs

logical, should stations be labeled? Defaults to TRUE

lab_loc

chr vector of 'R' and 'L', one letter for each station. if no lab_loc is specified then labels will default to the left.

bg_map

a georeferenced ggmap or ggplot object used as a background map, generally provided by a call to base_map. If bg_map is specified, maptype and zoom are ignored.

zoom

Zoom level for the base map created when bg_map is not specified. An integer value, 5 - 15, with higher numbers providing more detail. If not provided, a zoom level is autoscaled based on bbox parameters.

maptype

Background map type from Stamen Maps (http://maps.stamen.com/); one of c("terrain", "terrain-background", "terrain-labels", "terrain-lines", "toner", "toner-2010", "toner-2011", "toner-background", "toner-hybrid", "toner-labels", "toner-lines", "toner-lite", "watercolor").

Details

Creates a stylized, reserve-level base map for displaying seasonal kendall results from sk_seasonal. The user can specify the reserve and stations to plot. The user can also specify a bounding box. For multi-component reserves, the user should specify a bounding box that highlights the component of interest.

To display seasonal trends, the user must specify c('inc', 'dec', 'insig', 'insuff') for each station listed in the stations argument.

Value

returns a ggplot object.

Author(s)

Julie Padilla, Dave Eslinger

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
48
49
50
51
52
## A compact reserve

### set plotting parameters
stations <- sampling_stations[(sampling_stations$NERR.Site.ID == 'elk'
     & sampling_stations$Status == 'Active'
     & sampling_stations$isSWMP == "P"), ]$Station.Code
     to_match <- c('wq')
stns <- stations[grep(paste(to_match, collapse = '|'), stations)]
shp_fl <- elk_spatial
bounding_elk <- c(-121.8005, 36.7779, -121.6966, 36.8799)
trnds <- c('inc', 'dec', 'insuff', 'insig')

### Low zoom and default maptype plot (for CRAN testing, not recommended)
#    Lower zoom number gives coarser text and fewer features
(x_low <- res_sk_map('elk', stations = stns, sk_result = trnds,
                 bbox = bounding_elk, shp = shp_fl,
                 zoom = 10))



### Default zoom and maptype
x_def <- res_sk_map('elk', stations = stns, sk_result = trnds,
                 bbox = bounding_elk, shp = shp_fl)

### Higher zoom number gives more details, but those may not be visible
x_14 <- res_sk_map('elk', stations = stns, sk_result = trnds,
                 bbox = bounding_elk, shp = shp_fl,
                 zoom = 14)

### Different maptypes may be used.
x_terrain <- res_sk_map('elk', stations = stns, sk_result = trnds,
                 bbox = bounding_elk, shp = shp_fl,
                 maptype = 'terrain')
### A multicomponent reserve (showing two different bounding boxes)

#  set plotting parameters
stations <- sampling_stations[(sampling_stations$NERR.Site.ID == 'cbm'
         & sampling_stations$Status == 'Active'
         & sampling_stations$isSWMP == "P"), ]$Station.Code
         to_match <- c('wq')
stns <- stations[grep(paste(to_match, collapse = '|'), stations)]
shp_fl <- cbm_spatial
bounding_cbm_1 <- c(-77.393, 38.277, -75.553, 39.741)
bounding_cbm_2 <- c(-76.8,  38.7, -76.62,  38.85)
trnds <- c('inc', 'insuff', 'dec', 'insig')

#   plot
y <- res_sk_map('cbm', stations = stns, sk_result = trnds,
                 bbox = bounding_cbm_1, shp = shp_fl)

z <- res_sk_map('cbm', stations = stns, sk_result = trnds,
                 bbox = bounding_cbm_2, shp = shp_fl)

padilla410/SWMPrExtension documentation built on Dec. 29, 2021, 5:48 a.m.