add_tabledap: Add rerddap::tabledap data to a plotdap map

View source: R/add_tabledap.R

add_tabledapR Documentation

Add rerddap::tabledap data to a plotdap map

Description

add_tabledap adds the data from an 'rerddap::tabledap()' call to a 'plotdap' map

Usage

add_tabledap(
  plot,
  table,
  var,
  color = c("#132B43", "#56B1F7"),
  size = 1.5,
  shape = 19,
  animate = FALSE,
  cumulative = FALSE,
  ...
)

Arguments

plot

a plotdap object.

table

a tabledap object.

var

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

color

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

size

the size of the symbol.

shape

the shape of the symbol. For valid options, see the 'pch' values section on points. plot(0:25, 0:25, pch = 0:25) also gives a quick visual of the majority of possibilities.

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")

# test datasets in data folder to meet execution timings
# code given to extract the data


sardines <- rerddap::tabledap(
 'FRDCPSTrawlLHHaulCatch',
 fields = c('latitude',  'longitude', 'time', 'scientific_name', 'subsample_count'),
  'time>=2010-01-01', 'time<=2012-01-01',
  'scientific_name="Sardinops sagax"'
  )


p <- plotdap()
p1 <- add_tabledap(p, sardines, ~subsample_count)
p2 <- add_tabledap(p, sardines, ~log2(subsample_count))

# using base R plotting
p <- plotdap("base")
p <- add_tabledap(p, sardines, ~subsample_count)

# robinson projection
p <- plotdap(crs = "+proj=robin")
p <- add_tabledap(p, sardines, ~subsample_count)



plotdap documentation built on Oct. 18, 2023, 1:15 a.m.