add_griddap: Add rerddap::griddap() data to a plotdap map

Description Usage Arguments Value Examples

View source: R/add_griddap.R

Description

add_griddap adds the data from an 'rerddap::griddap() call to a 'plotdap' map

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
add_griddap(
  plot,
  grid,
  var,
  fill = "viridis",
  maxpixels = 10000,
  time = mean,
  animate = FALSE,
  cumulative = FALSE,
  ...
)

Arguments

plot

a plotdap object.

grid

a griddap object.

var

a formula defining a variable, or function of variables to visualize.

fill

either a character string of length 1 matching a name in the package cmocean or a vector of color codes. This defines the colorscale used to encode values of var.

maxpixels

integer > 0. Maximum number of cells to use for the plot. If maxpixels < ncell(x), sampleRegular is used before plotting. If gridded=TRUE maxpixels may be ignored to get a larger sample

time

how to resolve multiple time frames. Choose one of the following:

  • A function to apply to each observation at a particular location (mean is the default).

  • A character string (of length 1) matching a time value.

animate

whether to animate over the time variable (if it exists). Currently only implemented for method='ggplot2' and requires the gganimate package.

cumulative

- if animation should be cumulative -default FALSE

...

arguments passed along to geom_sf() (if method='ggplot2', otherwise ignored).

Value

A plotdap object

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
# base plotting tends to be faster,
# but is less extensible plotdap("base")

# actual datasets in data folder to meet execution timings


 murSST <- rerddap::griddap(
   'jplMURSST41', latitude = c(35, 40), longitude = c(-125, -120.5),
   time = c('last', 'last'), fields = 'analysed_sst'
  )

 QMwind <- rerddap::griddap(
   'erdQMwindmday', time = c('2016-11-16', '2017-01-16'),
   latitude = c(30, 50), longitude = c(210, 240),
   fields = 'x_wind'
 )

p <- plotdap(crs = "+proj=robin")
add_griddap(p, murSST, ~analysed_sst)

p <- plotdap(mapTitle = "Average wind over time")
add_griddap(p, QMwind, ~x_wind)



p <- plotdap("base", crs = "+proj=robin")
p <- add_griddap(p, murSST, ~analysed_sst)

# layer tables on top of grids
require(magrittr)
p <- plotdap("base") %>%
  add_griddap(murSST, ~analysed_sst) %>%
  add_tabledap(sardines, ~subsample_count)

# multiple time periods
p <- plotdap("base", mapTitle = "Average wind over time")
p <- add_griddap(p, QMwind, ~x_wind)

plotdap documentation built on Oct. 29, 2020, 1:07 a.m.