# \donttest{
# clickValues and family are unreliable on Rstudio Server as the plotting device
# does not report its dimensions correctly; this may change in future
# updates to Rstudio
if (interactive() && !isRstudioServer() ) {
files <- system.file("maps", package = "quickPlot")
files <- dir(files, full.names = TRUE, pattern = "tif")
maps <- lapply(files, function(x) terra::rast(x))
names(maps) <- sapply(basename(files), function(x) {
strsplit(x, split = "\\.")[[1]][1]
})
landscape <- c(maps$DEM, maps$forestCover, maps$habitatQuality)
clearPlot()
Plot(landscape)
clickValues(3) # click at three locations on the Plot device
clearPlot()
Plot(landscape)
e <- clickExtent() # click at two locations on the Plot device
print(e)
# repeated zooming to try various places on the original device
for(i in 1:4) clickExtent() # click at two locations on the Plot device
}
# }
Run the code above in your browser using DataLab