Skip to content

long 0-360, shift to -180 to 180

2 messages · Michael Loranty, Andy Bunn

#
Hi Andy,

I think the rotate function in the raster package might be what you're  
looking for.

Hope things are well with you.

-Mike

dat <- matrix(data = 1:100, nrow=360, ncol = 360)
 > bar <-  
raster(dat,xmn=0,xmx=356.25,ymn=-87.159094555863,ymx=87.159094555863,
+              crs="+proj=longlat +datum=WGS84")
 > bar
class       : RasterLayer
filename    :
nrow        : 360
ncol        : 360
ncell       : 129600
min value   : 1
max value   : 100
projection  : +proj=longlat +datum=WGS84
extent      : 0, 356.25, -87.1591, 87.1591  (xmin, xmax, ymin, ymax)
resolution  : 0.9895833, 0.4842172  (x, y)

 > bar2 <- rotate(bar)
 > bar2
class       : RasterLayer
filename    :
nrow        : 360
ncol        : 360
ncell       : 129600
min value   : 1
max value   : 100
projection  : +proj=longlat +datum=WGS84
extent      : -178.125, 178.125, -87.1591, 87.1591  (xmin, xmax, ymin,  
ymax)
resolution  : 0.9895833, 0.4842172  (x, y)
On Mar 10, 2011, at 6:00 AM, r-sig-geo-request at r-project.org wrote:

            
#
Ah. That's perfect. Thanks Mike. Raster is a potent library!