12.5 Create a Raster of the Temperature

library(terra) 
raster_template <- terra::rast(nrows = 18, ncols = 36,
                          xmin = 11, xmax = 28,
                          ymin = 2, ymax = 12,
                          crs = st_crs(df_sf)$proj4string)
ctr_africa_raster <- rasterize(df_sf,
                               raster_template,
                               field = "temperature",
                               fun = max)