0

I'm very new to using leaflet and the GBIF API in R, but I'm wondering how to display tiles up to a particular year (like 'year<=2015') rather than just the tiles with the year equivalent to a particular value ('year=2015')?

Thanks! The issue is, I think, with defining the year in the following code:

library(leaflet)


projection = '3857' # projection code
style = 'style=gbif-middle'
tileRaster = paste0('https://tile.gbif.org/',projection,'/omt/{z}/{x}/{y}@1x.png?',style)

prefix = 'https://api.gbif.org/v2/map/occurrence/density/{z}/{x}/{y}@1x.png?'
polygons = 'style=classic.poly&bin=hex&hexPerTile=100' 
datasetKey = 'datasetKey=cc09386c-43a4-4a12-8ae4-d25610645250'
year= 'year <= 1955' #THIS is what I'm having trouble with
tilePolygons = paste0(prefix, polygons,'&',datasetKey, '&',year)

leaflet() %>%
  setView(lng = 5.4265362, lat = 43.4200248, zoom = 01) %>%
  addTiles(urlTemplate=tileRaster) %>%
  addTiles(urlTemplate=tilePolygons)  

It 'works' and shows all collections for year 2015 when I run:

year= 'year=2015'

but what I want is to include all data up to the year 2015.

EML
  • 1
  • 1
  • 1
  • URLs are not fond of spaces. Could the spaces in the year string be causing the issue? 'year<=1955' – Susan Switzer Oct 06 '22 at 19:16
  • Thanks @SusanSwitzer! That didn't work, but I'll keep working on it and will update when I figure it out. – EML Oct 12 '22 at 02:10

0 Answers0