I have around 300 rasters of climate data (annual average precipitation and temperature). Each raster represents the global average for that year. Each raster is named by respective year e.g. 1900 etc. I then have a shapefile with museum specimen information. This includes the coordinates where they were collected and the year of collection. I want to extract the climate variables for each coordinate but only when the collection year is the same as the name of the raster file. Then I need to loop this for all my rasters. So far I can extract the climate data for all coordinates using extract(1900, coordinates). Where 1900 is the name of raster and coordinates is name of shapefile.
I tried using the if command on just one raster if(coordinates$CollYear==1900, { extract(1900, coordinates) }
But this doesn’t work.
As to how I select based on the raster file name, I have no idea.
Any tips would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire