rxtractogon: Extract environmental data in a polygon using 'ERDDAP' and...

View source: R/rxtractogon.R

rxtractogonR Documentation

Extract environmental data in a polygon using 'ERDDAP' and 'rerddap'.

Description

rxtractogon uses the R program 'rerddap' to extract environmental data from an 'ERDDAP' server in a polygon through time.

Usage

rxtractogon(
  dataInfo,
  parameter,
  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

- array giving longitudes (in decimal degrees East, either 0-360 or -180 to 180) of polygon

ycoord

- array giving latitudes (in decimal degrees N; -90 to 90)of polygon

zcoord

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

tcoord

- 2-array of minimum and maximum times as 'YYYY-MM-DD'

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

If successful a structure with data and dimensions

  • extract$data - the masked 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

else an error string

Details

rxtractogon extracts the data from the smallest bounding box that contains the polygon, and then uses the function "point.in.polygon" from the "sp" package to mask out the areas outside of the polygon. rxtractogon only works with datasets defined on a latitude and longitude grid.

Examples

## toy example to show use
## and keep execution time low
# dataInfo <- rerddap::info('erdHadISST')
parameter <- 'sst'
tcoord <- c("2016-06-15")
xcoord <- mbnms$Longitude[1:3]
ycoord <- mbnms$Latitude[1:3]
# sanctSST <- rxtractogon (dataInfo, parameter=parameter, xcoord = xcoord,
#                          ycoord = ycoord,  tcoord= tcoord)
#
## MBMS bathymetry example
xcoord <- mbnms$Longitude
ycoord <- mbnms$Latitude
dataInfo <- rerddap::info('etopo180')
parameter = 'altitude'
xName <- 'longitude'
yName <- 'latitude'
# bathy <- rxtractogon (dataInfo, parameter = parameter, xcoord = xcoord, ycoord = ycoord)

rmendels/rerddapXtracto documentation built on Jan. 19, 2024, 6:28 p.m.