-2

I want to to a raster object that has x coordinates (longitude) from 0 to 360, to standard coordinates between -180 and 180 degrees.

I have a matrix where the longitude range is (0,360) and the latitude range is (-90,90) and has a resolution of 0.75 so that its dimensions are

dim(x)
[1] 480 241

Then I try

r <- rotate(x)

And I get this error

Error in rotate(x) : object "phy" is not of class "phylo"
Roland
  • 127,288
  • 10
  • 191
  • 288
user3910073
  • 511
  • 1
  • 6
  • 23

1 Answers1

2

Try raster::rotate(x). You happen to have loaded the ape package after you loaded the raster package; both packages contain rotate functions. (Another alternative would be to detach("package:ape") and try again.)

If you type find("rotate") R will tell you where it's finding the function; the first element of the vector is the one it chooses by default.

When you loaded ape you should have gotten the following message:

Attaching package: ‘ape’
The following objects are masked from ‘package:raster’:
    rotate, zoom
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453