0

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')"

2 Answers 2

1

This is a non-issue warning and is associated with the migration of spatial packages to the new WKT format coming from GDAL/PROJ. You can suppress the warning by issuing options("rgdal_show_exportToProj4_warnings"="none") before adding any packages or adding to your Rprofile.site file.

If you search the site for [R] projection there are many discussions on this. But, do not reproject your data to the same projection as a means of dealing with it. You can try using sf::st_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") to construct the WKT projection and assigning it as the CRS but, I do not think raster supports it just yet.

1

You've not told extract_covariates which locations in your raster you want to extract the covariates from.

In the help examples you can see the deer locations are used to get covariates from the forest info:

deer %>% extract_covariates(sh_forest)

by piping the deer into the function. It looks like you neglected to pipe some locations into your raster stack. I think not using pipes would stop people making this mistake, and you should do something like:

deer_forest_covariates = extract_covariates(deer, sh_forest)

2
  • Thank you, it worked! But even if the .tif files have data assigned on each pixel, the resulting columns give NA for each row. Any suggestions?
    – stifosss
    Mar 24, 2021 at 19:18
  • sounds like a different problem - start a new question and give the details of your spatial data and if possible some maps.
    – Spacedman
    Mar 24, 2021 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.