I am trying to download occurrence data of multiple taxonomic groups from multiple regions using the R package rgbif. I prefer to have one download by combining all the regions together (because I have thousands of regions, it would be insane to have separate downloads). However, I did not find a way to do so. I can do occ_download for one region per query.
Here are my exemplary code:
library(rgbif)
gbif_taxon_keys = c(212, 359)
# below are bbox of 3 regions;
# I have polygons as WKT, but they are clockwise
# (how to convert to counter clockwise??)
wkts = c("POLYGON((11.3431 47.2451,11.4638 47.2451,11.4638 47.2919,11.3431 47.2919,11.3431 47.2451))",
"POLYGON((12.9644 47.7608,13.0922 47.7608,13.0922 47.8453,12.9644 47.8453,12.9644 47.7608))",
"POLYGON((14.2284 48.2217,14.3669 48.2217,14.3669 48.3443,14.2284 48.3443,14.2284 48.2217))")
# this works
queries = occ_download_prep(
pred_in("taxonKey", gbif_taxon_keys),
pred("hasCoordinate", TRUE),
pred("hasGeospatialIssue", FALSE),
pred_within(wkts[1]),
user = gbif_user, pwd = gbif_pwd,
email = gbif_email)
out_test = occ_download_queue(.list = list(queries))
# now try to combine regions in one download
# this does not work
queries = occ_download_prep(
pred_in("taxonKey", gbif_taxon_keys),
pred("hasCoordinate", TRUE),
pred("hasGeospatialIssue", FALSE),
pred_within(wkts),
user = gbif_user, pwd = gbif_pwd,
email = gbif_email)
out_test = occ_download_queue(.list = list(queries))
Error: 'value' must be length 1
# this does not work neither (it runs though)
queries = occ_download_prep(
pred_in("taxonKey", gbif_taxon_keys),
pred("hasCoordinate", TRUE),
pred("hasGeospatialIssue", FALSE),
pred("geometry", paste0(wkts, collapse = ";")),
user = gbif_user, pwd = gbif_pwd,
email = gbif_email)
out_test = occ_download_queue(.list = list(queries))
<<gbif download metadata>>
Status: KILLED
From my download center on GBIF, it says "The download request was unsuccessful. ".
Can anyone help with this? Thanks!
I think I figured out how to do this. I just combined all polygons into a multipolygon and it seems works.
In another word, I just put the above 3 polygon into this:
then, I run:
It works for this example. @sckott may have better approaches.