9.2 Add a temperature raster

If we were interested in the latitudinal temperature gradient, we could add a raster of mean temperature as a background to our map. We will use a low resolution so it does not take to long.

temp <- getData("worldclim", var = "tmean", res = 10, path =  "data")
#R>  Warning in getData("worldclim", var = "tmean", res = 10, path = "data"): getData will be removed in a future version of raster
#R>  . Please use the geodata package instead
# Change projection to match with the polygons
temp <- projectRaster(temp, crs = st_crs(qc_simple)$proj4string)
#R>  Warning in projectRaster(temp, crs = st_crs(qc_simple)$proj4string): input and
#R>  ouput crs are the same
# There are 12 layers in this raster.
# Keep only the layer for June temperature: tmean6 and divide by 10 (because Worldclim temperature data are in °C * 10)
temp6 <- temp$tmean6 / 10