You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unrecognized CRS in RStudio console, functions as expected in Terminal #10052
RStudio Edition : Desktop
RStudio Version : 2021.09.0 Build 351
OS Version : Windows 10 x64 (build 19042)
R Version : R version 4.1.2 (2021-11-01)
Describe the problem in detail
Defining a legitimate Coordinate Reference System (CRS) in the RStudio Console draws an unexpected error that does not occur when run in the Terminal. See rspatial/raster#232 for background on this issue.
Steps to reproduce the problem
From the RStudio Console in a clean new project:
> library(raster)
# Loading required package: sp
> x <- raster(xmn=273366.5, xmx=1870587, ymn=359771.8, ymx=1735721, crs="EPSG:3005")
# Error in sp::CRS(SRS_string = x) : NA
>crs(x)
# CRS arguments: NA
From the RStudio Terminal:
> library(raster)
#Loading required package: sp
> x <- raster(xmn=273366.5, xmx=1870587, ymn=359771.8, ymx=1735721, crs="EPSG:$
> writeRaster(x, driver='GTiff', filename='x.tif', overwrite=T)
# Warning message:
# In .local(x, filename, ...) : all cell values are NA
> crs(x)
# 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
Describe the behavior you expected
The following result should occur whether invoked from RStudio or directly from within R:
I see the same behavior with RGui 4.1.1, and I also see the same behavior in an R process launched as a child from an RStudio session, so I don't think this is specific to RStudio.
This issue still occurs with the latest versions of R, sp package and RStudio. The problem only occurs in the RStudio Console. When R is run in the terminal it performs as expected.
################
# In RStudio Terminal
C:\Users\user1\Documents>R
R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> 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
###############
# In RStudio Console
> sp::CRS("EPSG:3005")
Error in sp::CRS("EPSG:3005") : NA
Activity
kevinushey commentedon Nov 5, 2021
I see the same behavior with RGui 4.1.1, and I also see the same behavior in an R process launched as a child from an RStudio session, so I don't think this is specific to RStudio.
tylerdrudolph commentedon Nov 5, 2021
@kevinushey I am seeing this problem recurring in Rterm as well now.
Closing this for the time being and re-opening rspatial/raster#232.
tylerdrudolph commentedon Nov 19, 2021
This issue still occurs with the latest versions of R, sp package and RStudio. The problem only occurs in the RStudio Console. When R is run in the terminal it performs as expected.
tylerdrudolph commentedon Nov 22, 2021
Any idea at RStudio as to what might be causing this? Or suggestions as to what I might try next?
@kevinushey are you still encountering this problem? Does the following fail in both R and Studio Console?
kevinushey commentedon Feb 3, 2022
This is what I'm seeing now:
However, the issue went away after I installed the
rgdalR package, e.g. with(and then restarting R and re-running the example).
So it seems like the behavior here somehow depends on the
rgdalpackage being installed, at least for me.github-actions commentedon Aug 3, 2022
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.
tylerdrudolph commentedon Aug 3, 2022
This issue no longer occurs for me since migrating all programs from rgdal/raster/sp toward sf, terra and gdalUtilities.