Learn R Programming

raster (version 3.0-2)

click: Query by clicking on a map

Description

Click on a map (plot) to get values of a Raster* or Spatial* object at that location; and optionally the coordinates and cell number of the location. For SpatialLines and SpatialPoints you need to click twice (draw a box).

Usage

# S4 method for Raster
click(x, n=Inf, id=FALSE, xy=FALSE, cell=FALSE, type="n", show=TRUE, ...)

# S4 method for SpatialGrid click(x, n=1, id=FALSE, xy=FALSE, cell=FALSE, type="n", ...)

# S4 method for SpatialPolygons click(x, n=1, id=FALSE, xy=FALSE, type="n", ...)

# S4 method for SpatialLines click(x, ...)

# S4 method for SpatialPoints click(x, ...)

Arguments

x

Raster*, or Spatial* object (or missing)

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

cell

Logical. If TRUE, cell numbers 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

show

logical. Print the values after each click?

...

additional graphics parameters used if type != "n" for plotting the locations. See ?locator

Value

The value(s) of x at the point(s) clicked on (or touched by the box drawn).

See Also

select, drawExtent

Examples

Run this code
# NOT RUN {
 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