1

Two maps with different extents

I am using R to process two maps (raster package). I have two maps with both WGS84 coordinates see figure. image of map

But one layer is from -180 to 180 in longitude (the map on surface) another one is from 0 to 360 (the map on the bottom).

I need to adjust the bottom layer to -180 to 180 so that they can match. How can I do that?

I think I need to find all grid greater than 180 and then minus 360. But I cannot find the longitude vector and cannot modify it from the Raster data.

Description of the map is:

class       : RasterLayer 
dimensions  : 94, 192, 18048  (nrow, ncol, ncell)
resolution  : 1.865234, 1.883872  (x, y)
extent      : 0, 358.125, -88.542, 88.542  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
data source : in memory
names       : TMAX_2015_01_01 
values      : 220.9, 324.3  (min, max)
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
  • Does [this post](http://stackoverflow.com/questions/5353184/fixing-maps-library-data-for-pacific-centred-0-360-longitude-display) help? – jazzurro Dec 19 '16 at 06:59

2 Answers2

0

spTransform(ws_soil,CRS=CRS("+proj=longlat +ellps=WGS84 +pm=+360 +datum=WGS84 +no_defs"))

You need to play with "+pm=+360" or "+pm=-360"

Nahm
  • 143
  • 1
  • 5
  • I tried to apply the surface map based on your suggestions. But it gives me a strange feedback. The extent of new map change to -540 to -180 not (0, 360). Is there anything wrong? – Tianyi Zhang Dec 20 '16 at 07:22
  • just play with numbers and plus and minus sign – Nahm Dec 20 '16 at 19:01
0

Others told me a good function (raster::rotate) Simply use CLIM_NEW<-rotate (CLIM_old). That will work.