plot_scatter {shinyscholar} | R Documentation |
Extract values from a raster to produce a scatterplot
Description
Called by the plot_scatter module in the example app and samples values from a raster along with either the x or y coordinates of the points sampled
Usage
plot_scatter(raster, sample, axis, name, logger = NULL)
Arguments
raster |
SpatRaster. Raster to be sampled |
sample |
numeric. Number of points to sample |
axis |
character. Which axis coordinates of the raster to return |
name |
character. The name of the raster variable |
logger |
Stores all notification messages to be displayed in the Log Window. Insert the logger reactive list here for running in shiny, otherwise leave the default NULL |
Value
a function that generates a scatterplot
Author(s)
Simon Smart simon.smart@cantab.net
Examples
if (check_suggests(example = TRUE)) {
raster <- terra::rast(ncol = 8, nrow = 8)
raster[] <- sapply(1:terra::ncell(raster), function(x){
rnorm(1, ifelse(x %% 8 != 0, x %% 8, 8), 3)})
scatterplot <- plot_scatter(raster, sample = 10, axis = "Longitude", name = "Example")
scatterplot()
} else {
message('reinstall with install.packages("shinyscholar", dependencies = TRUE)
to run this example')
}
[Package shinyscholar version 0.4.2 Index]