Skip to main content
2 of 2
deleted 22 characters in body
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Importing raster files warning and extracting covariates error with 'raster' and 'amt' packages in R

I am using 'amt' package in RStudio, trying to assess habitat selection of a species in an area with telemetry data. My two preliminary problems are:

  1. When I import the land data rasters (elevation and land cover) I get this warning message:
Warning message:
In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
  Discarded datum Unknown based on GRS80 ellipsoid in Proj4 definition

Is this something to worry about? Since all the individuals' shapefiles and the land data files are in epsg:2100 (Greek Grid) already before importing them in RStudio? I also tried importing them in epsg:4326 (WGS84) but I get the same warning, and also transforming them with transform_coords() function but again get the same warning. Moreover, I tried using the proj4 for the projection that I use, but I still get the same warning.

landcover = projectRaster(landcover, crs="+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=-199.87,74.79,246.62,0,0,0,0 +units=m +no_defs")

#or

landcover = crs("+proj=tmerc +lat_0=0 +lon_0=24 +k=0.9996 +x_0=500000 +y_0=0 +ellps=GRS80 +towgs84=-199.87,74.79,246.62,0,0,0,0 +units=m +no_defs")
  1. When I try to extract covariates from the raster files, I get this error, which I have not figured out how to fix.
Error in UseMethod("extract_covariates", x) : 
  no applicable method for 'extract_covariates' applied to an object of class
 "c('RasterStack', 'Raster', 'RasterStackBrick', 'BasicRaster')"

I have already checked the .tif files in ArcMap and they have identical dimensions, and the pixels have values (elevation and land cover of each pixel).

Any suggestions?

Code:

library(amt)
library(raster)
library(tidyverse)
library(lubridate)
library(sf)

#Import the land_cover and elevation rasters
landcover = raster("landcover.tif")

#Warning message:
#In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
#  Discarded datum Unknown based on GRS80 ellipsoid in Proj4 definition

elevation = raster("elevation.tif")

#Warning message:
#In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
#  Discarded datum Unknown based on GRS80 ellipsoid in Proj4 definition

map <- stack(landcover, elevation) 
plot(map) #I can plot and see the maps
extract_covariates(map, where = "both") #Also tried to extract covariates without using stack()

#Error in UseMethod("extract_covariates", x) : 
#  no applicable method for 'extract_covariates' applied to an object of class
# "c('RasterStack', 'Raster', 'RasterStackBrick', 'BasicRaster')"