I have a raster file that extends longitudinally from 0° to 360°. Using R, I'd like to wrap the raster at 180°, so that longitudes between 180° and 360° are translated to the interval [-180°, 0°]. Is there an existing function or package that can do this?


Use the raster package:

x <- raster(somefilename)

"rotate" does this task (0/360 to -180/180), and that is all it does.
Otherwise it's reasonably straightforward to crop() to separate longitude ranges, shift() one of them in "x", and merge() them back together.

See ?rotate and findMethods("rotate")[["Raster"]] for details of what the function does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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