Closed andersfi closed 6 years ago
The first thing I noticed was that the WKT includes some extra commas in tuple 3 and 4: 'geometry = POLYGON((9.33 62.80,9.33 64.20,12.13,64.20,12.13,62.80,9.33 62.80))' 'geometry = POLYGON((9.33 62.80,9.33 64.20,12.13 64.20,12.13 62.80,9.33 62.80))'
A web search in the portal gives 66 hits https://www.gbif.org/occurrence/search?country=NO&has_coordinate=true&has_geospatial_issue=false&taxon_key=2346633&geometry=POLYGON((9.33%2062.80,%209.33%2064.20,%2012.13%2064.20,%2012.13%2062.80,%209.33%2062.80))
GBIF REST API search gives 66 hits http://api.gbif.org/v1/occurrence/search?taxon_key=2346633&country=NO&has_coordinate=true&has_geospatial_issue=false&geometry=POLYGON((9.33%2062.80,%209.33%2064.20,%2012.13%2064.20,%2012.13%2062.80,%209.33%2062.80))
Testing with rgbif occ_search() also gives 66 hits
sp_data <- (occ_search (taxonKey = '2346633', hasCoordinate = 'TRUE',
hasGeospatialIssue = 'FALSE',
country = 'NO',
geometry = 'POLYGON((9.33 62.80, 9.33 64.20, 12.13 64.20, 12.13 62.80, 9.33 62.80))',
limit=100))$data
But for some reason using the occ_download() still gives me an error on the GBIF portal side.
sp_downloadKey <- (occ_download ('taxonKey = 2346633', 'hasCoordinate = TRUE',
'hasGeospatialIssue = FALSE',
'country = NO',
'geometry = POLYGON((9.33 62.80,9.33 64.20,12.13 64.20,12.13 62.80,9.33 62.80))',
type = "and"))[1]
I get the request posted to the GBIF portal API, but find this error message: "Broken download. The download request was unsuccessful. Please try it again or get in touch." See download URL: https://www.gbif.org/occurrence/download/0002836-171113114016250
When I click "RERUN QUERY" in the failed download request page, I do get the 66 hits https://www.gbif.org/occurrence/download/0002836-171113114016250
When I make the same search in R without the geometry attribute, I do get hits (3317 hits)
sp_downloadKey <- (occ_download ('taxonKey = 2346633', 'hasCoordinate = TRUE',
'hasGeospatialIssue = FALSE',
'country = NO',
type = "and"))[1]
https://www.gbif.org/occurrence/download/0002855-171113114016250
Fixed in #2, confirmed and merged by @andersfi
I can't (for some reason) don't get my head around using polygons as filtering in occ_download (probably just a stupid error somewhere).
This will return "Error: Bad Request (HTTP 400)". (with the line 'geometry..." hashed out it works fine). Full example in the "Search and request download key" section of async_download_gbif.Rmd