我想开发一个用户可以在图像shiny
上绘制多边形的应用程序。raster
用户完成多边形绘制后,我希望应用程序向他们显示所选像素的表格。
例如,terra
提供一个draw
可以用作draw("polygon")
. 但是,我无法让它与我的shiny
应用程序一起使用。
该应用程序的基本思想如下(我已用 注释了有问题的部分#
):
library(terra)
library(shiny)
r = rast(system.file("ex/elev.tif", package="terra"))
ui = fluidPage(
plotOutput("map"),
tableOutput("chosen_pixels")
)
server = function(input, output, session) {
output$map = renderPlot({
plot(r)
# draw("polygon") # I comment it otherwise the app does not run
})
# output$chosen_pixels = renderPlot({
# here I want to write code that shows a table of chosen pixels
#})
}
shinyApp(ui, server)