The longitude in CMIP5 future climate data is in 0 - 360 degree. How can I convert it to -180 - 180 degree using the raster package?
I tried with shift(r0,-180)
and shift(r0,-360)
. It does not work. Any help will be appreciated. r0
here is a raster.
This is kind of a hack and there's probably a much easier way to do that in
raster
, but here is an option. First, you need to create a matrix from your raster object, then modify some longitude values (only the ones that are > 180) and switch back to a raster. Themarmap
package can do the back and forth switching for you:It's pretty simple:
Try
rotate()
. Its help page even mentions its utility with the type of data you're dealing with:Here's a simple reproducible example to show what it does: