When trying to use the get_elev_raster from the elevatr package, I am running into an error which seems a few libraries deep. As a basic reprex:

luxembourg <- readRDS(url("https://biogeo.ucdavis.edu/data/gadm3.6/Rsf/gadm36_LUX_0_sf.rds")) %>%
elevation <- get_elev_raster(luxembourg, z = 4)

old-style crs object detected; please recreate object with a recent sf::st_crs()
old-style crs object detected; please recreate object with a recent sf::st_crs()
Error in sp::CRS(SRS_string = "EPSG:4326") : 
  no arguments in initialization list

(the old style crs warnings this throws for me doesn't seem to be related to the error per se but might be useful in diagnosing)

When running similar on my local R version everything works perfectly, however, for my actual use case I'm running this on RStudio server using a GCP virtual machine.

I can't seem to re-find it, but in the issues for sp:: I think it was pointed out that this error is actually from rgdal. Both my local and vm rgdal versions are 1.5-23.

My VM gdal is GDAL 2.4.0, released 2018/12/14 My local gdal is GDAL 3.0.4, released 2020/01/28 so I imagine this is something to do with things, but grateful for any advice!!

  • What's your PROJ versions? It should be given on doing library(sf) and library(rgdal), and those two packages might not be using the same.
    – Spacedman
    Sep 5, 2021 at 13:51
  • If you can use debug and step through get_elev_raster it might be informative to find out where it stops. The code appears to do some testing of PROJ version before deciding on something, and maybe its doing the wrong thing at that point for you. Can't replicate your error on my current setup, might try some older versions via docker later.
    – Spacedman
    Sep 5, 2021 at 14:02
  • Tried with "GEOS 3.7.1, GDAL 2.4.0, PROJ 5.2.0", no problem, also with "GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1", no problem. We really need your specifics.
    – Spacedman
    Sep 6, 2021 at 13:14
  • in my case a reinstallation of rdgal with install.packages("rgdal", repos="http://R-Forge.R-project.org") and setting rgdal::set_proj_search_paths("C:/Users/Christof/Documents/R/win-library/4.1/rgdal/proj") as described here github.com/jhollist/elevatr/issues/48#issuecomment-1059802332 had fixed the same problem
    – ckluss
    Mar 18 at 17:27


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.