【发布时间】:2021-12-21 23:20:21
【问题描述】:
我想开发一个shiny 应用程序,用户可以在其中在raster 图像上绘制多边形。用户绘制完多边形后,我希望应用程序向他们显示所选像素的表格。
例如,terra 提供了一个函数draw,可以用作draw("polygon")。但是,我无法让它与我的 shiny 应用程序一起使用。
app的基本思路如下(有问题的部分我已经用#注释掉了):
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)
【问题讨论】:
标签: r shiny raster r-raster terra