Description Usage Arguments Details Note Author(s) See Also Examples
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.
1 2 3 | chooseRegion(sp = TRUE, proj = CRS("+proj=latlon +ellps=WGS84"))
## S4 method for signature 'Raster'
identifyRaster(object, layer=1, values=FALSE, pch=13, cex=0.6, col='black',...)
|
sp |
logical, if TRUE the result is a |
proj |
A character string for the |
object |
A Raster object. |
layer |
A numeric or character which should indicate the layer to be chosen. |
values |
logical, if TRUE the values are returned. |
pch, cex, col |
Graphical parameters for |
... |
Additional arguments for
|
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
).
chooseRegion
needs the package mgcv
to be installed.
Oscar Perpiñán Lamigueiro
panel.identify
,panel.link.splom
, trellis.focus
, grid.locator
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | f <- system.file("external/test.grd", package="raster")
r <- raster(f)
levelplot(r)
##Do not close the last graphical window
##Use the left button of the mouse to identify points and the right button to finish
chosen_r <- identifyRaster(r, values=TRUE)
chosen_r
s <- stack(r, r-500, r+500)
levelplot(s)
chosen_s <- identifyRaster(s, values=TRUE)
chosen_s
## Not run:
##The package mgcv is needed for the next example
##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.
levelplot(s)
reg <- chooseRegion()
summary(reg)
## End(Not run)
## Not run:
##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')
stackSIS <- stack(listFich)
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)
names(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)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.