R Error in CRS(x): PROJ4 argument-value pairs must begin with +

Viewed 1229

read a color space image into a variable

img <- stack('BlueMarbleJuly.tif')

project the raster into a nes coordinate system. Project Robinson

img.merc <- projectRaster(img, crs = st_crs(3857)[[2]])

and I get an error

Error in CRS(x) : PROJ4 argument-value pairs must begin with +: PROJCRS["WGS 84 / Pseudo-Mercator", BASEGEOGCRS["WGS 84", DATUM["World Geodetic System 1984", ELLIPSOID["WGS 84",6378137,298.257223563, LENGTHUNIT["metre",1]]], PRIMEM["Greenwich",0, ANGLEUNIT["degree",0.0174532925199433]], ID["EPSG",4326]], CONVERSION["Popular Visualisation Pseudo-Mercator", METHOD["Popular Visualisation Pseudo Mercator", ID["EPSG",1024]], PARAMETER["Latitude of natural origin",0, ANGLEUNIT["degree",0.0174532925199433], ID["EPSG",8801]], PARAMETER["Longitude of natural origin",0, ANGLEUNIT["degree",0.0174532925199433], ID["EPSG",8802]], PARAMETER["False easting",0, LENGTHUNIT["metre",1], ID["EPSG",8806]], PARAMETER["False northing",0, LENGTHUNIT["metre",1], ID["EPSG",8807]]], CS[Cartesian,2],

what does it mean?

1 Answers

You are providing projectRaster with a "wkt" representation of a coordinate reference system, but it expects a "proj4" representation. To fix this, you can do

img.merc <- projectRaster(x, crs = "+init=epsg:3857")

As in

library(raster)
f <- system.file("external/test.grd", package="raster")
x <- raster(f)
merc <- projectRaster(x, crs = "+init=epsg:3857")
Related