Dear list,
I am trying to combine two rasters. One raster has global coverage, while other covers only Amazon.
Let me show in pratice. First I create an emtpy structure with the intended domain (global) and resolution (0.5 degree):
class : RasterLayer
dimensions : 360, 720, 259200 (nrow, ncol, ncell)
resolution : 0.5, 0.5 (x, y)
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
values : in memory
min value : NA
max value : NA
On the other hand, I load a Amazon deforestation file which contains values between 0 and 1:
amz<-raster("/home/data/amz.img")
amz
class : RasterLayer
dimensions : 47, 65, 3055 (nrow, ncol, ncell)
resolution : 0.5, 0.5 (x, y)
extent : -74, -41.5, -17.5, 6 (xmin, xmax, ymin, ymax)
coord. ref. : NA
values : /home/data/amz.img
min value : 0
max value : 1
Next, I apply the same projection:
projection(amz) <- projection(glb)
amz
class : RasterLayer
dimensions : 47, 65, 3055 (nrow, ncol, ncell)
resolution : 0.5, 0.5 (x, y)
extent : -74, -41.5, -17.5, 6 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
values : /home/data/amz.img
min value : 0
max value : 1
Last, after trying to replace NA values in the global raster with the values of the amazon object,
result <- cover(glb,amz)
a erratic stripe across the globe is produced, like showed in this image: http://img269.imageshack.us/img269/1328/errorau.png
Does anyone have a suggestion to solve this problem?
Thanks in advance,
Thiago.