edzer / sp

Classes and methods for spatial data
http://edzer.github.io/sp/
127 stars 27 forks source link

Unrecognized CRS in RStudio #111

Open tylerdrudolph opened 2 years ago

tylerdrudolph commented 2 years ago

Invoking certain legitimate EPSG codes draws errors on my machine, seemingly only in RStudio but occasionally in Rterm as well:

# RStudio console
> sp::CRS("EPSG:3005")
Error in sp::CRS("EPSG:3005") : NA

# RStudio terminal
> sp::CRS("EPSG:3005")
CRS arguments:
+proj=aea +lat_0=45 +lon_0=-126 +lat_1=50 +lat_2=58.5 +x_0=1000000
+y_0=0 +datum=NAD83 +units=m +no_defs

R and packages are up-to-date and I am testing in a clean environment:

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252    LC_MONETARY=English_Canada.1252 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.1.2  rgdal_1.5-27    tools_4.1.2     sp_1.4-5        grid_4.1.2      lattice_0.20-45

See https://github.com/rspatial/raster/issues/232 and https://github.com/rstudio/rstudio/issues/10052 for background. Is this an sp or an RStudio problem?

kevinushey commented 2 years ago

Can you also share the output of traceback() after the error occurs? It might help pinpoint which function call is failing underneath the hood.

tylerdrudolph commented 2 years ago

By all means @kevinushey.

> traceback()
2: stop(res[[2]])
1: sp::CRS("EPSG:3005")
KarHarker commented 2 years ago

Any luck figuring this out @tylerdrudolph? Having the same problem

tylerdrudolph commented 2 years ago

@KarHarker As of today, all my packages are up-to-date, yet the issue persists. My solution is to progressively rework all active code such that it no longer references CRS(), instead using sf::st_crs(), and the terra package in lieu of raster.