powered by
Click on a map (plot) to get values of a SpatRaster at that location; and optionally the coordinates and cell number of the location. For SpatVectors you need to click twice (draw a box).
# S4 method for SpatRaster click(x, n=Inf, id=FALSE, xy=FALSE, cell=FALSE, type="n", show=TRUE, ...)
SpatRaster or SpatVector, or missing
number of clicks on the plot (map)
Logical. If TRUE, a numeric ID is shown on the map that corresponds to the row number of the output
TRUE
Logical. If TRUE, xy coordinates are included in the output
Logical. If TRUE, cell numbers are included in the output
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
logical. Print the values after each click?
additional graphics parameters used if type != "n" for plotting the locations. See ?locator
The value(s) of x at the point(s) clicked on (or touched by the box drawn).
x
draw
# NOT RUN { r <-rast(system.file("exdata/test.tif", package="terra")) plot(r) click(r) # now click on the plot (map) # }
Run the code above in your browser using DataLab