add_griddap {plotdap}R Documentation

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

Description

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

Usage

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


# 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")
p <- add_griddap(p, murSST, ~analysed_sst)

 # p <- plotdap(mapTitle = "Average wind over time")
 # p <- 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)


[Package plotdap version 1.0.3 Index]