E Exercise 03
Last updated: 2022-02-21 17:13:53
E.1 Question 1
- Read the raster
MOD13A3_2000_2019.tif
to a multi-band raster object namedr
. - Calculate a vector of length 24 with the correlation coefficients between the values of the layer 1, and the values of layers 1, 2, …, 24.
- To calculate correlation coefficients use the
cor
function with theuse="pairwise.complete.obs"
argument, as in:cor(x, y, use="pairwise.complete.obs")
. - For example, the 2nd value in the vector should be equal to:
## [1] 0.9752619
- Plot the values of the vector, as shown in Figure E.1.
- Remember: you cannot use the
raster
package in your solution! (see Section B.6.5.) - Note: the two arguments passed to the
cor
function, i.e., the pixel values of layer 1 and layer n, need to be either vectors or arrays (not matrices). If necessary, amatrix
can be converted to a vector withas.vector
.
(50 points)
E.2 Question 2
- Read the raster
MOD13A3_2000_2019.tif
to a multi-band raster object namedr
. - Create a single-band raster
s
, marking areas with relatively high NDVI, relatively low NDVI, and large amount ofNA
, as follows:- Pixels where the maximal non-
NA
NDVI value across all 233 bands ofr
is ≥0.2, will have a value of1
ins
- Pixels where the maximal non-
NA
NDVI value across all 233 bands ofr
is <0.2, will have a value of0
ins
- Pixels where the proportion of
NA
values is >0.2 (regardless of NDVI values), will have a value ofNA
ins
- Pixels where the maximal non-
- Plot the raster
s
with values of0
marked in"orange"
and values of1
marked in"darkgreen"
(values ofNA
will be transparent, by default) - Remember: you cannot use the
raster
package in your solution! (see Section B.6.5.)
(50 points)