raster (version 1.1.7)

click: Click

Description

Click on a plot (map) of a RasterLayer to get values of a Raster* object at a location; and optionally the coordinates for the location. Multiple locations can be clicked on by specifying n=.

Usage

click(object, n=1, id=FALSE, xy=FALSE, type = "n", ...)

Arguments

object
RasterLayer or RasterStack object
n
number of clicks on the map
id
Logical. If TRUE, a numeric ID is shown on the map that corresponds to the row number of the output
xy
Logical. If TRUE, xy coordinates are included in the output
type
One of "n", "p", "l" or "o". If "p" or "o" the points are plotted; if "l" or "o" they are joined by lines. See ?locator
...
additional graphics parameters used if type != "n" for plotting the locations. See ?locator

Value

  • The value(s) of object at the point(s) clicked on; and the coordinates of the center of the cell if xy==TRUE.

See Also

drawExtent

Examples

Run this code
r <- raster(system.file("external/test.grd", package="raster"))
#plot(r)
#click(r)
#now click on the plot (map)

Run the code above in your browser using DataLab