8

I am trying to set the CRS of a raster file with the following code:

library(raster)
r<-raster(xmn=0,xmx=10,ymn=0,ymx=10)
crs(r)<-CRS("+init=epsg:3035")

The warning message is:

Warning message:
In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum European_Terrestrial_Reference_System_1989 in CRS definition

How can I succesfully change the CRS to EPSG 3035?

If I set the CRS to WGS84 I don't get any warning.

5
  • 4
    Its only a warning, so the CRS should be set. Is it? rgdal.r-forge.r-project.org/articles/… for more info on changes in CRS in R because PROJ.
    – Spacedman
    Commented Jun 18, 2020 at 15:24
  • Yes, it's "just" a warning but I cannot intersect the resulting raster with any other sf-geometry. The error message is that the CRS are not equal, even though the features are both set to 3035.
    – Funkwecker
    Commented Jun 19, 2020 at 6:06
  • 1
    I cannot reproduce your error. The code works perfectly on my system; no warning whatsoever and raster with CRS = +init=epsg:3035 +proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs. System Info: LinuxMint19.3 + R3.6.3 + raster3.1-5 + sp1.4-2 + rgdal1.5-10 Commented Jun 21, 2020 at 17:22
  • 1
    You should be aware that due to changes in PROJ that the EPSG definition will no longer be supported at something in the near future. Commented Aug 2, 2020 at 13:39
  • @Jeffery Evans: I think the disabling of proj.4 strings with proj version 8 is a general problem where the current proj developers are only promoting their own perspective. However, they do not take into account the existing code around the world, especially existing libraries. This is not a good development and advice like "you should change your code does not help in principle" (keyword sustainability).
    – huckfinn
    Commented Dec 24, 2021 at 23:54

1 Answer 1

1

Im suffering from the same problem. Tried to read in raster files with CRS set to EPSG:3067. Same message of ETRS89 datum being discarded arises.

One can add manually the information to the crs-string. I just do not believe that this actually fixes the problem.

#EXAMPLE OF ADDING DATUM INFO TO CRS STRING

library(raster)

file = raster("yourFilePath)
crsInfo <- slot(file, "crs")
slot(crsInfo, "projargs") <- paste0(slot(crsInfo, "projargs"), " +datum=GRS80")
slot(file, "crs") <- crsInfo

1
  • 3
    Wow, that is convoluted when proj4string(x) <- "+init=epsg:3035" do the same thing. The error is arising due to the transition to WKT projection definitions and the changes in GDAL and PROJ. Just ignore them. Commented Aug 2, 2020 at 13:41

Your Answer

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

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