Accessing Environmental Data from ERD's ERDDAP Server

Contains three functions that access environmental data from ERD's ERDDAP service <>. The xtracto() function extracts data along a trajectory for a given "radius" around the point. The xtracto_3D() function extracts data in a box. The xtractogon() function extracts data in a polygon. There are also two helper functions to obtain information about available data, and plotting functions to plot the results.

xtractomatic R package for accessing environmental data

***Version 3.4.1 ****

  • Changes to the order of the function arguments and required and option arguments in the functions.

  • See vignette for lots of examples - https://

xtractomatic is an R package developed to subset and extract satellite and other oceanographic related data from a remote server. The program can extract data for a moving point in time along a user-supplied set of longitude, latitude and time points; in a 3D bounding box; or within a polygon (through time). The xtractomatic functions were originally developed for the marine biology tagging community, to match up environmental data available from satellites (sea-surface temperature, sea-surface chlorophyll, sea-surface height, sea-surface salinity, vector winds) to track data from various tagged animals or shiptracks (xtracto). The package has since been extended to include the routines that extract data a 3D bounding box (xtracto_3D) or within a polygon (xtractogon). The xtractomatic package accesses data that are served through the ERDDAP (Environmental Research Division Data Access Program) server at the NOAA/SWFSC Environmental Research Division in Santa Cruz, California. The ERDDAP server can also be directly accessed at ERDDAP is a simple to use yet powerful web data service developed by Bob Simons.

There are three main data extraction functions in the xtractomatic package:

  • xtracto <- function(dtype, xpos, ypos, tpos = NA, xlen = 0., ylen = 0., verbose=FALSE)

  • xtracto_3D <- function(dtype, xpos, ypos, tpos = NA, verbose=FALSE)

  • xtractogon <- function(dtype, xpos, ypos, tpos = NA, verbose = FALSE)

There are two information functions in the xtractomatic package:

  • `searchData <- function(searchList= "varname:chl")

  • getInfo <- function(dtype)

The dtype parameter in the data extraction routines specifies a combination of which dataset on the ERDDAP server to access, and as well as which parameter from that dataset.

This version also includes the latest version of the cmocean colormaps, designed by Kristen Thyng (see and These colormaps were initally developed for Python, and a version of the colormaps is used in the oce package by Dan Kelley and Clark Richards, but the colormaps used here are the version as of late 2017. The colormaps are loaded automatically as colors, see str(colors). Several of the examples make use of the cmocean colormaps.

xtractomatic uses the httr, ncdf4, readr and sp packages, and these packages must be installed first or xtractomatic will fail to install.

install.packages("httr", dependencies = TRUE)
install.packages("ncdf4",dependencies = TRUE) 
install.packages("readr", dependencies = TRUE)
install.packages("sp", dependencies = TRUE)

The xtractomatic package is available from CRAN and can be installed by:


or the development version is available from [Github]( and can be installed from Github,


If the other libraries (httr, ncdf4, readr and sp) have been installed they will be found and do not need to be explicitly loaded.

The vignette uses the packages DT, ggplot2, lubridate, mapdata, and reshape2.

Required legalese

“The United States Department of Commerce (DOC) GitHub project code is provided on an ‘as is’ basis and the user assumes responsibility for its use. DOC has relinquished control of the information and no longer has responsibility to protect the integrity, confidentiality, or availability of the information. Any claims against the Department of Commerce stemming from the use of its GitHub project will be governed by all applicable Federal law. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by the Department of Commerce. The Department of Commerce seal and logo, or the seal and logo of a DOC bureau, shall not be used in any manner to imply endorsement of any commercial product or activity by DOC or the United States Government.”


xtractomatic 3.4.1

Changed so URL sends ISO time, not udunits time.

xtractomatic 3.4.0

  • Major refactoring of code, order of function arguments and defaults has changed.
  • searchData() no longer uses a list of list, instead it uses a simple list where the each “searchType” and “searchString” are set off by a colon as in “searchType:searchString”.
  • Added cmocean colormaps.
  • Added check if dataset is available.
  • Better checks if download fails at any point.
  • If xtracto() call fails part-way through, results to that point returned.
  • Changed some examples for faster execution.

xtractomatic 3.3.2

added back in ncdcOisst2Agg dataset

xtractomatic 3.3.1

Changed examples to run faster on CRAN machines.

xtractomatic 3.3.0

  • Changed the organization of the underlying erddapStruct that contains dataset information, removed outdated datasets.
  • Changed searchData() to use a simple list with text strings of the form searchType:searchText
  • Corrected searchData() for case where there are no matches
  • searchData() and getInfo() now return results using View().
  • Modified encoding of urls to work with newer versions of Apache Tomcat.

xtractomatic 3.2.0

  • Changed to using https instead of http.
  • Examples dataset changed as previous one is no longer available
  • Vignette now makes multiple tries to get the data
  • getFileCoords() now makes multiple tries to get the dataset coordinate values

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


3.4.1 by Roy Mendelssohn, a month ago

Report a bug at

Browse source code at

Authors: Roy Mendelssohn [aut, cre], Cindy Bessey [ctb], Dave Foley [ctb]

Documentation:   PDF Manual  

CC0 license

Imports dplyr, httr, ncdf4, readr, sp, stats, utils

Suggests DT, ggplot2, knitr, lubridate, mapdata, reshape2, rmarkdown, webshot

See at CRAN