This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

## libraries
library(raster)
## Loading required package: sp
## load data
load("z:/R_programming/06_WUR_Geoscripting/Original_Github_repo/Advanced_raster_analysis/AdvancedRasterAnalysis-gh-pages/data/GewataB2.rda")
load("z:/R_programming/06_WUR_Geoscripting/Original_Github_repo/Advanced_raster_analysis/AdvancedRasterAnalysis-gh-pages/data/GewataB3.rda")
load("z:/R_programming/06_WUR_Geoscripting/Original_Github_repo/Advanced_raster_analysis/AdvancedRasterAnalysis-gh-pages/data/GewataB4.rda")


# check out the attributes
GewataB2
## class       : RasterLayer 
## dimensions  : 1177, 1548, 1821996  (nrow, ncol, ncell)
## resolution  : 30, 30  (x, y)
## extent      : 808755, 855195, 817635, 852945  (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=utm +zone=36 +ellps=WGS84 +units=m +no_defs 
## data source : in memory
## names       : gewataB2 
## values      : 127, 2220  (min, max)
# some basic statistics using cellStats()
cellStats(GewataB2, stat=max)
## [1] 2220
cellStats(GewataB2, stat=mean)
## [1] 502.9058
# This is equivalent to:
maxValue(GewataB2)
## [1] 2220
# what is the maximum value of all three bands?
max(c(maxValue(GewataB2), maxValue(GewataB3), maxValue(GewataB4)))
## [1] 4903
# summary() is useful function for a quick overview
summary(GewataB2)
##         gewataB2
## Min.         127
## 1st Qu.      410
## Median       469
## 3rd Qu.      594
## Max.        2220
## NA's           0
# put the 3 bands into a rasterBrick object to summarize together
gewata <- brick(GewataB2, GewataB3, GewataB4)
# 3 histograms in one window (automatic, if a rasterBrick is supplied)
hist(gewata)

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.