Skip to content

Raster Layers same resolution but not the same coordinates over the same area

3 messages · Justin Michell, Robert J. Hijmans

#
Hi Jonathan

I tried that.. But I am but the results don?t make sense:
x         y     NDVI1     NDVI2    NDVI3     NDVI4    NDVI5     NDVI6     NDVI7     NDVI8     NDVI9    NDVI10    NDVI11    NDVI12
1 29.42809 -1.002081 0.7196462 0.6093929 0.614475 0.7851786 0.799475 0.7241929 0.5946000 0.5948500 0.6585143 0.7874357 0.8305786 0.7774929
2 29.43662 -1.002081 0.7103154 0.5823500 0.572225 0.7867429 0.794050 0.7445643 0.6033786 0.5635429 0.6421857 0.7802786 0.8300643 0.7886786
3 29.44514 -1.002081 0.7303692 0.6254571 0.599350 0.7771143 0.785850 0.7510071 0.6404571 0.6197286 0.6770929 0.7686786 0.8169571 0.7957786
4 29.45367 -1.002081 0.7641923 0.6890714 0.657850 0.7936786 0.809975 0.7805429 0.6769643 0.6590714 0.7165357 0.7843357 0.8283286 0.8231500
5 29.46220 -1.002081 0.8057769 0.7500714 0.718175 0.8208786 0.838575 0.8126500 0.7345786 0.7359571 0.7661214 0.8087214 0.8442643 0.8380071
6 29.47073 -1.002081 0.8065615 0.7627071 0.730550 0.8142214 0.841100 0.8252000 0.7574786 0.7425071 0.7590571 0.8025071 0.8518357 0.8430286
x         y rain1 rain2 rain3 rain4 rain5 rain6 rain7 rain8 rain9 rain10 rain11 rain12
1 29.42917 -1.004167    66    68    85   116   105    61    40    85   110    125    118     85
2 29.43750 -1.004167    66    69    85   117   106    61    40    85   110    125    119     86
3 29.44583 -1.004167    66    68    84   116   106    60    39    84   110    124    118     85
4 29.45417 -1.004167    65    67    83   116   105    60    39    83   108    123    117     84
5 29.46250 -1.004167    65    68    83   117   106    59    38    83   109    124    118     84
6 29.47083 -1.004167    66    68    84   118   107    59    38    83   110    125    119     85
values ind
1 29.42809   x
2 29.43662   x
3 29.44514   x
4 29.45367   x
5 29.46220   x
6 29.47073   x

Is there a better way maybe without using data frames?

I tried stacking the stacks too:
Error in compareRaster(x) : different number or columns
class       : RasterStack 
dimensions  : 1287, 1321, 1700127, 12  (nrow, ncol, ncell, nlayers)
resolution  : 0.008333333, 0.008333333  (x, y)
extent      : 29.425, 40.43333, -11.725, -1  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
names       : rain1, rain2, rain3, rain4, rain5, rain6, rain7, rain8, rain9, rain10, rain11, rain12 
min values  :     7,     5,    31,    13,     0,     0,     0,     0,     0,      0,     22,     32 
max values  :   391,   392,   563,   746,   473,   159,   109,   106,   164,    247,    349,    464
class       : RasterStack 
dimensions  : 1258, 1291, 1624078, 12  (nrow, ncol, ncell, nlayers)
resolution  : 0.008526982, 0.008525437  (x, y)
extent      : 29.425, 40.43333, -11.725, -1  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
names       :      NDVI1,      NDVI2,      NDVI3,      NDVI4,      NDVI5,      NDVI6,      NDVI7,      NDVI8,      NDVI9,     NDVI10,     NDVI11,     NDVI12 
min values  : -0.1524615, -0.1353071, -0.1970500, -0.1632071, -0.1919250, -0.1647286, -0.1665000, -0.1693357, -0.1852643, -0.1733714, -0.1555357, -0.1682571 
max values  :  0.9153615,  0.9013000,  0.9295500,  0.9134643,  0.9421750,  0.9158357,  0.9000071,  0.9009786,  0.8733571,  0.8792429,  0.9151357,  0.9233000 

Thanks 
Justin
On Jun 30, 2014, at 5:55 PM, Jonathan Greenberg <jgrn at illinois.edu> wrote:

            
#
My apologies, I forgot to send as plain text.
On Aug 30, 2014, at 1:27 PM, Justin Michell <jwm302 at gmail.com> wrote:

            
#
Justin,

The RasterStack approach is fine, but as you show, the layers do not
match. The resolution of NDVIStack is larger than the resolution of
rainStack; it seems that you did not resample the NDVI data correctly.

Robert
On Sat, Aug 30, 2014 at 4:31 AM, Justin Michell <jwm302 at gmail.com> wrote: