Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antweb removed #203

Merged
merged 1 commit into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Title: Interface to Species Occurrence Data Sources
Description: A programmatic interface to many species occurrence data sources,
including Global Biodiversity Information Facility ('GBIF'), 'USGSs'
Biodiversity Information Serving Our Nation ('BISON'), 'iNaturalist',
Berkeley 'Ecoinformatics' Engine, 'eBird', 'AntWeb', Integrated Digitized
Berkeley 'Ecoinformatics' Engine, 'eBird', Integrated Digitized
'Biocollections' ('iDigBio'), 'VertNet', Ocean 'Biogeographic' Information
System ('OBIS'), and Atlas of Living Australia ('ALA'). Includes
functionality for retrieving species occurrence data, and combining
Expand Down
7 changes: 0 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ S3method(as.ala,data.frame)
S3method(as.ala,list)
S3method(as.ala,occdat)
S3method(as.ala,occkey)
S3method(as.antweb,antwebkey)
S3method(as.antweb,character)
S3method(as.antweb,data.frame)
S3method(as.antweb,list)
S3method(as.antweb,occdat)
S3method(as.antweb,occkey)
S3method(as.bison,bisonkey)
S3method(as.bison,character)
S3method(as.bison,data.frame)
Expand Down Expand Up @@ -68,7 +62,6 @@ S3method(print,occnames)
S3method(summary,occdat)
S3method(summary,occdatind)
export(as.ala)
export(as.antweb)
export(as.bison)
export(as.ecoengine)
export(as.gbif)
Expand Down
84 changes: 0 additions & 84 deletions R/antweb_helpers.R

This file was deleted.

73 changes: 0 additions & 73 deletions R/as.antweb.R

This file was deleted.

4 changes: 1 addition & 3 deletions R/inspect.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @param x The output from \code{\link{occ}} call, output from call to
#' \code{\link{occ2df}}, or an occurrence ID as a occkey class.
#' @param from (character) The data provider. One of gbif, bison, inat,
#' antweb, ecoengine, or vertnet
#' ecoengine, or vertnet
#' @return A list, with each slot named for the data source, and then
#' within data sources is a slot for each taxon, named by it's occurrence ID.
#'
Expand Down Expand Up @@ -52,7 +52,6 @@ inspect.occkey <- function(x, from="gbif"){
gbifkey = as.gbif(x),
bisonkey = as.bison(x),
ecoenginekey = as.ecoengine(x),
antwebkey = as.antweb(x),
idigbiokey = as.idigbio(x))
}

Expand All @@ -65,7 +64,6 @@ make_df <- function(x){
gbif = as.gbif(obj[[i]]),
bison = as.bison(obj[[i]]),
ecoengine = as.ecoengine(obj[[i]]),
antweb = as.antweb(obj[[i]]),
idigbio = as.idigbio(obj[[i]])
)
}
Expand Down
11 changes: 4 additions & 7 deletions R/occ.r
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ occ <- function(query = NULL, from = "gbif", limit = 500, start = NULL,
page = NULL, geometry = NULL, has_coords = NULL, ids = NULL, date = NULL,
callopts=list(),
gbifopts = list(), bisonopts = list(), inatopts = list(),
ebirdopts = list(), ecoengineopts = list(), antwebopts = list(),
ebirdopts = list(), ecoengineopts = list(),
vertnetopts = list(), idigbioopts = list(), obisopts = list(),
alaopts = list()) {

Expand Down Expand Up @@ -39,7 +39,7 @@ occ <- function(query = NULL, from = "gbif", limit = 500, start = NULL,
}
}
sources <- match.arg(from, choices = c("gbif", "bison", "inat", "ebird",
"ecoengine", "antweb", "vertnet", "idigbio", "obis", "ala"),
"ecoengine", "vertnet", "idigbio", "obis", "ala"),
several.ok = TRUE)
if (!all(from %in% sources)) {
stop(
Expand All @@ -63,13 +63,12 @@ occ <- function(query = NULL, from = "gbif", limit = 500, start = NULL,
inat_res <- foo_inat(sources, x, y, p, z, hc, d, w, inatopts)
ebird_res <- foo_ebird(sources, x, y, w, ebirdopts)
ecoengine_res <- foo_ecoengine(sources, x, y, p, z, hc, d, w, ecoengineopts)
antweb_res <- foo_antweb(sources, x, y, s, z, hc, d, w, antwebopts)
vertnet_res <- foo_vertnet(sources, x, y, hc, d, w, vertnetopts)
idigbio_res <- foo_idigbio(sources, x, y, s, z, hc, d, w, idigbioopts)
obis_res <- foo_obis(sources, x, y, s, z, hc, d, w, obisopts)
ala_res <- foo_ala(sources, x, y, s, z, hc, d, w, alaopts)
list(gbif = gbif_res, bison = bison_res, inat = inat_res, ebird = ebird_res,
ecoengine = ecoengine_res, antweb = antweb_res, vertnet = vertnet_res,
ecoengine = ecoengine_res, vertnet = vertnet_res,
idigbio = idigbio_res, obis = obis_res, ala = ala_res)
}

Expand All @@ -90,7 +89,6 @@ occ <- function(query = NULL, from = "gbif", limit = 500, start = NULL,
inat = list(time = NULL, data = data_frame()),
ebird = list(time = NULL, data = data_frame()),
ecoengine = list(time = NULL, data = data_frame()),
antweb = list(time = NULL, data = data_frame()),
vertnet = list(time = NULL, data = data_frame()),
idigbio = list(time = NULL, data = data_frame()),
obis = list(time = NULL, data = data_frame()),
Expand Down Expand Up @@ -259,13 +257,12 @@ occ <- function(query = NULL, from = "gbif", limit = 500, start = NULL,
inat_sp <- getsplist("inat", inatopts)
ebird_sp <- getsplist("ebird", ebirdopts)
ecoengine_sp <- getsplist("ecoengine", ecoengineopts)
antweb_sp <- getsplist("antweb", antwebopts)
vertnet_sp <- getsplist("vertnet", vertnetopts)
idigbio_sp <- getsplist("idigbio", idigbioopts)
obis_sp <- getsplist("obis", obisopts)
ala_sp <- getsplist("ala", alaopts)
p <- list(gbif = gbif_sp, bison = bison_sp, inat = inat_sp, ebird = ebird_sp,
ecoengine = ecoengine_sp, antweb = antweb_sp, vertnet = vertnet_sp,
ecoengine = ecoengine_sp, vertnet = vertnet_sp,
idigbio = idigbio_sp, obis = obis_sp, ala = ala_sp)
structure(p, class = "occdat", searched = from)
}
14 changes: 5 additions & 9 deletions R/occ2df.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#' \item key - occurrence record key
#' }
#'
#' AntWeb doesn't provide dates, so occurrence rows from that provider
#' are blank.
#'
#' @examples \dontrun{
#' # combine results from output of an occ() call
#' spnames <- c('Accipiter striatus', 'Setophaga caerulescens',
Expand Down Expand Up @@ -74,7 +71,6 @@ occ2df.occdat <- function(obj, what = "data") {
cc <- foolist(obj$inat)
dd <- foolist(obj$ebird)
ee <- foolist(obj$ecoengine)
aw <- foolist(obj$antweb)
vn <- foolist(obj$vertnet)
id <- foolist(obj$idigbio)
ob <- foolist(obj$obis)
Expand All @@ -97,26 +93,26 @@ occ2df.occdat <- function(obj, what = "data") {
rename(dat, stats::setNames("key", keymap[[y]]))
}
},
list(aa, bb, cc, dd, ee, aw, vn, id, ob, ala),
c('gbif','bison','inat','ebird','ecoengine','antweb',
list(aa, bb, cc, dd, ee, vn, id, ob, ala),
c('gbif','bison','inat','ebird','ecoengine',
'vertnet','idigbio','obis','ala')
)
)
tmpout <- list(
meta = list(obj$gbif$meta, obj$bison$meta, obj$inat$meta,
obj$ebird$meta, obj$ecoengine$meta, obj$aw$meta, obj$vn$meta,
obj$ebird$meta, obj$ecoengine$meta, obj$vn$meta,
obj$id$meta, obj$ob$meta, obj$ala$meta),
data = tmp
)
if (what %in% "data") as_data_frame(tmpout$data) else tmpout
}

datemap <- list(gbif = 'eventDate', bison = 'date', inat = 'observed_on',
ebird = 'obsDt', ecoengine = 'begin_date', antweb = NULL,
ebird = 'obsDt', ecoengine = 'begin_date',
vertnet = "eventdate", idigbio = "datecollected",
obis = "eventDate", ala = "eventDate")

keymap <- list(gbif = "key", bison = "occurrenceID", inat = "id",
ebird = "locID", ecoengine = "key", antweb = "catalogNumber",
ebird = "locID", ecoengine = "key",
vertnet = "occurrenceid", idigbio = "uuid", obis = "id",
ala = "uuid")
4 changes: 1 addition & 3 deletions R/occ_options.r
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@
#' strings too (e.g., 'rv' for 'rvertnet').
#'
#' For some data sources we don't import the canonical package, but instead
#' have our own intenral helper functions and the package in question is
#' have our own internal helper functions and the package in question is
#' not imported, but we do suggest seeing the help for the package on
#' their parameters:
#'
#' \itemize{
#' \item **AntWeb**: `?AntWeb::aw_data`
#' \item **ecoengine**: `?ecoengine::ee_observations`
#' }
#'
#' For others,
#' @examples \dontrun{
#' # opens up documentation for this function
#' occ_options()
Expand Down
49 changes: 0 additions & 49 deletions R/plugins.r
Original file line number Diff line number Diff line change
Expand Up @@ -149,55 +149,6 @@ foo_ecoengine <- function(sources, query, limit, page, geometry, has_coords,
}
}


#' @noRd
foo_antweb <- function(sources, query, limit, start, geometry, has_coords,
date, callopts, opts) {
if (any(grepl("antweb", sources))) {
time <- now()
opts$georeferenced <- has_coords
# limit <- NULL
geometry <- NULL

query <- sub("^ +", "", query)
query <- sub(" +$", "", query)

if (length(strsplit(query, " ")[[1]]) == 2) {
opts$scientific_name <- query
} else {
opts$genus <- query
opts$scientific_name <- NULL
}

if (!is.null(date)) {
if (length(date) != 2) stop("'date' for Ecoengine must be length 2")
opts$min_date <- date[1]
opts$max_date <- date[2]
}

if (!'limit' %in% names(opts)) opts$limit <- limit
if (!'offset' %in% names(opts)) opts$offset <- start
if (length(callopts) > 0) opts$callopts <- callopts
out <- tryCatch(do.call(aw_data2, opts), error = function(e) e)

if (is.null(out) || inherits(out, "simpleError") || NROW(out$data) == 0) {
warning(sprintf("No records found in AntWeb for %s", query),
call. = FALSE)
emptylist(opts)
} else {
res <- out$data
res$prov <- rep("antweb", nrow(res))
res$name <- query
res <- stand_latlon(res)
res <- add_latlong_if_missing(res)
list(time = time, found = out$count, data = as_data_frame(res),
opts = opts)
}
} else {
emptylist(opts)
}
}

#' @noRd
foo_bison <- function(sources, query, limit, start, geometry, date,
callopts, opts) {
Expand Down
Loading