I have a raster in WGS 1984 coordinate system with the pixel values denoting categorical values i.e. the raster is a land use land cover raster, with each value meaning water bodies, ice, forest etc.

I need to convert it to the unamed ellipse sinusoidal projection (with a linear unit of meters), since my remaining rasters are in this projection. I have tried-

projectRaster(raster in WGS 1984 system, crs(raster in sinusoidal projection), method='ngb' since my raster is categorical as mentioned above).

I get this error message- Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘res’ for signature ‘"CRS"’.

In context to this question, what does the error message mean and how do I solve it such that the projection works.

1 Answer 1


The help for projectRaster looks like this:

 projectRaster(from, to, res, crs, method="bilinear", 
              alignOnly=FALSE, over=FALSE, filename="", ...) 

When you do projectRaster(r1, r2) it matches the from and to arguments, and the to argument has to be:

 to: Raster* object with the parameters to which 'from' should be

a raster object. But you fed it crs(raster object). You don't need to use crs if you have a raster, you can feed it the two rasters:

 r3 = projectRaster(r1, r2)

should work. If you only have a crs object, you have to name the parameter so it matches the crs argument rather than the to argument:

cc = crs(r2)
r3 = projectRaster(r1, crs=cc)

should also work.

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.