rspatial / geodata

download geographic data
GNU General Public License v3.0
147 stars 15 forks source link

`sp_occurrence()` fails when `end>100000` #63

Open AMBarbosa opened 6 months ago

AMBarbosa commented 6 months ago

If end >100,000, an error message is shown, even if start is large enough for the total number of records to be OK:

sp_occurrence(genus = "Lutra", download = FALSE) 
[1] 243745

sp_occurrence(genus = "Lutra", start=100000, end=100001)
# Error in sp_occurrence(genus = "Lutra", start = 1e+05, end = 100001) : 
  GBIF does not allow using this service for record numbers that are > 100,000

I submitted a pull request (#62) that seems to fix that. After applying that fix, the download does start, but then seems to fail under most circumstances, though not all - ignore the wacky reported number of downloaded records, which is the subject of a separate issue (#64):

sp_occurrence(genus = "Lutra", start = 99999, end=100001)  # OK:
# 3 records found
# 99998-100001
# 100001 records downloaded
#                acceptedNameUsageID       acceptedScientificName [...]
# 1 urn:lsid:dyntaxa.se:Taxon:100077 Lutra lutra (Linnaeus, 1758) [...]
# 2 urn:lsid:dyntaxa.se:Taxon:100077 Lutra lutra (Linnaeus, 1758) [...]
# 3 urn:lsid:dyntaxa.se:Taxon:100077 Lutra lutra (Linnaeus, 1758) [...]

sp_occurrence(genus = "Lutra", start = 99999, end=100002) 
# 4 records found
# 99998-download failed
# NULL