Is it possible to use the argument “geometry” with the function occ_download?
I’m trying to retrieve gbif data using the occ_download function. When I include the geometry, I get the following error message:
occ_download('taxonKey = 7228682', 'hasCoordinate = TRUE', 'hasGeospatialIssue = FALSE', 'geometry=POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))')
Error: Could not resolve type id '{' into a subtype of [simple type, class org.gbif.api.model.occurrence.predicate.Predicate]
at [Source: HttpInputOverHTTP@51b1daac; line: 1, column: 289]
I have also tried to include ‘decimalLatitude’ and ‘decimalLongitude’. But it also does not work.
occ_download('taxonKey = 7228682', 'hasCoordinate = TRUE', 'hasGeospatialIssue = FALSE',
'decimalLatitude >= -20','decimalLatitude <= -2',
'decimalLongitude >= -53', 'decimalLongitude <=-28', type = 'or')
Error: Could not resolve type id '{' into a subtype of [simple type, class org.gbif.api.model.occurrence.predicate.Predicate]
at [Source: HttpInputOverHTTP@16b169d2; line: 1, column: 495]
Yes, it’s possible to use geometry parameter with occ_download().
I tried your code, and you needed some spaces, so occ_download('taxonKey = 7228682', 'hasCoordinate = TRUE', 'hasGeospatialIssue = FALSE', 'geometry = POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))') should work, note spaces at geometry = POLYGON...
For the 2nd query, it appears that’s another case where spaces are needed around symbols, that is 'decimalLongitude <= -28' instead of 'decimalLongitude <=-28' - will fix in the issue at https://github.com/ropensci/rgbif/issues/217
I’ve also fixed the parsing of inputs to occ_download in the package, see https://github.com/ropensci/rgbif/issues/217 - Reinstall from Github like devtools::install_github("ropensci/rgbif") - and those changes and others should be on CRAN soon.