Learn R Programming

rasterVis (version 0.10-2)

Interaction: Interaction with trellis objects.

Description

chooseRegion provides a set of points (in the form of a SpatialPoints) inside a region defined by several mouse clicks. identifyRaster labels and returns points of a trellis graphic according to mouse clicks.

Usage

chooseRegion(sp = TRUE, proj = CRS("+proj=latlon +ellps=WGS84"))
## S3 method for class 'Raster':
identifyRaster(object, layer=1, values=FALSE, pch=13, cex=0.6, col='black',...)

Arguments

docType

methods

Details

When called, these functions wait for the user to identify points (in the panel being drawn) via mouse clicks. Clicks other than left-clicks close the region (for chooseRegion) and the procedure (for identifyRaster).

See Also

panel.identify,panel.link.splom, trellis.focus, grid.locator

Examples

Run this code
##Solar irradiation data from CMSAF
##Data available from http://www.box.net/shared/rl51y1t9sldxk54ogd44

old <- getwd()
##change to your folder...
setwd('CMSAF')
listFich <- dir(pattern='2008')
listNC <- lapply(listFich, raster)
stackSIS <- do.call(stack, listNC)
stackSIS <- stackSIS*24 ##from irradiance (W/m2) to irradiation Wh/m2
setwd(old)

idx <- seq(as.Date('2008-01-15'), as.Date('2008-12-15'), 'month')

SISmm <- setZ(stackSIS, idx)
layerNames(SISmm) <- month.abb

levelplot(SISmm)

##Do not close the last graphical window
##Interaction
##Use the left button of the mouse to identify points and the right button to finish
chosen <- identifyRaster(SISmm, layer=3, values=TRUE)
chosen
##Use the left button of the mouse to build a border with points, and the right button to finish.
##The points enclosed by the border will be highlighted and returned as a SpatialPoints object.
reg <- chooseRegion()
summary(reg)

Run the code above in your browser using DataLab