Learn R Programming

rerddapXtracto (version 0.4.5)

rxtracto_3D: Extract environmental data in a 3-dimensional box from an 'ERDDAP' server using 'rerddap'.

Description

rxtracto_3D uses the R program 'rerddap' to extract environmental data from an 'ERDDAP' server in an (x,y,z, time) bounding box. The same call could be made directly in rerddap, but function is maintained as it is used in the polygon routine.

Usage

rxtracto_3D(dataInfo, parameter = NULL, xcoord = NULL, ycoord = NULL,
  zcoord = NULL, tcoord = NULL, xName = "longitude",
  yName = "latitude", zName = "altitude", tName = "time",
  verbose = FALSE, cache_remove = TRUE)

Arguments

dataInfo

- the return from an 'rerddap:info' call to an 'ERDDAP' server

parameter

- character string containing the name of the parameter to extract

xcoord

- a real array with the x-coordinates of the trajectory (if longitude in #' decimal degrees East, either 0-360 or -180 to 180)

ycoord

- a real array with the y-coordinate of the trajectory (if latitude in decimal degrees N; -90 to 90)

zcoord

- a real array with the z-coordinate (usually altitude or depth)

tcoord

- a character array with the times of the trajectory in "YYYY-MM-DD" - for now restricted to be time.

xName

- character string with name of the xcoord in the 'ERDDAP' dataset (default "longitude")

yName

- character string with name of the ycoord in the 'ERDDAP' dataset (default "latitude")

zName

- character string with name of the zcoord in the 'ERDDAP' dataset (default "altitude")

tName

- character string with name of the tcoord in the 'ERDDAP' dataset (default "time")

verbose

- logical variable (default FALSE) if the the URL request should be verbose

cache_remove

- logical variable (default TRUE) whether to delete 'rerddap' cache

Value

structure with data and dimensions:

  • extract$data - the data array dimensioned (lon,lat,time)

  • extract$varname - the name of the parameter extracted

  • extract$datasetname - ERDDAP dataset name

  • extract$longitude - the longitudes on some scale as request

  • extract$latitude - the latitudes always going south to north

  • extract$time - the times of the extracts

Examples

Run this code
# NOT RUN {
# toy example to show use
# and keep execution time low
# }
# NOT RUN {
dataInfo <- rerddap::info('erdHadISST')
# }
# NOT RUN {
parameter <- 'sst'
xcoord <- c(-130.5, -130.5)
ycoord <- c(40.5, 40.5)
tcoord <- c('2006-01-16', '2006-01-16')
extract <- rxtracto_3D(dataInfo, parameter, xcoord = xcoord, ycoord = ycoord,
                       tcoord = tcoord)

# }
# NOT RUN {
# 2-D example getting bathymetry
dataInfo <- rerddap::info('etopo360')
parameter <- 'altitude'
extract <- rxtracto_3D(dataInfo, parameter, xcoord = xcoord, ycoord = ycoord)
# Dataset that has depth also
# 3 months of subsurface temperature at 70m depth from SODA 2.2.4
dataInfo <- rerddap::info('erdSoda331oceanmday')
parameter = 'temp'
xName <- 'longitude'
yName <- 'latitude'
zName <- 'depth'
xcoord <- c(230.25, 250.25)
ycoord <- c(30.25, 43.25)
zcoord <- c(5.03355, 15.10065)
tcoord <- c('2010-10-15', '2010-12-15')
extract <- rxtracto_3D(dataInfo, parameter, xcoord = xcoord, ycoord = ycoord,
                       zcoord = zcoord, tcoord = tcoord, xName = xName,
                       yName = yName, zName = zName)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab