# NOT RUN {
# occ_download("basisOfRecord = LITERATURE")
# occ_download('taxonKey = 3119195')
# occ_download('decimalLatitude > 50')
# occ_download('elevation >= 9000')
# occ_download('decimalLatitude >= 65')
# occ_download("country = US")
# occ_download("institutionCode = TLMF")
# occ_download("catalogNumber = Bird.27847588")
# download format
# z <- occ_download('decimalLatitude >= 75', format = "SPECIES_LIST")
# res <- occ_download('taxonKey = 7264332', 'hasCoordinate = TRUE')
# pass output directly, or later, to occ_download_meta for more information
# occ_download('decimalLatitude > 75') %>% occ_download_meta
# Multiple queries
# occ_download('decimalLatitude >= 65', 'decimalLatitude <= -65', type="or")
# gg <- occ_download('depth = 80', 'taxonKey = 2343454', type="or")
# complex example with many predicates
# shows example of how to do date ranges for both year and month
# res <- occ_download(
# "taxonKey = 2480946,5229208",
# "basisOfRecord = HUMAN_OBSERVATION,OBSERVATION,MACHINE_OBSERVATION",
# "country = US",
# "hasCoordinate = true",
# "hasGeospatialIssue = false",
# "year >= 1999",
# "year <= 2011",
# "month >= 3",
# "month <= 8"
# )
# Using body parameter - pass in your own complete query
## as JSON
query1 <- '{"creator":"sckott",
"notification_address":["myrmecocystus@gmail.com"],
"predicate":{"type":"and","predicates":[
{"type":"equals","key":"TAXON_KEY","value":"7264332"},
{"type":"equals","key":"HAS_COORDINATE","value":"TRUE"}]}
}'
# res <- occ_download(body = query1, curlopts=list(verbose=TRUE))
## as a list
library(jsonlite)
query <- list(
creator = unbox("sckott"),
notification_address = "myrmecocystus@gmail.com",
predicate = list(
type = unbox("and"),
predicates = list(
list(type = unbox("equals"), key = unbox("TAXON_KEY"),
value = unbox("7264332")),
list(type = unbox("equals"), key = unbox("HAS_COORDINATE"),
value = unbox("TRUE"))
)
)
)
# res <- occ_download(body = query, curlopts = list(verbose = TRUE))
# Prepared query
occ_download_prep("basisOfRecord = LITERATURE")
occ_download_prep("basisOfRecord = LITERATURE", format = "SIMPLE_CSV")
occ_download_prep("basisOfRecord = LITERATURE", format = "SPECIES_LIST")
# }
Run the code above in your browser using DataLab