Use requireNamespace instead of require to load raster package.