- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在一个 Shiny 的应用程序中工作,它可以让您知道哪些地方适合您居住,这是正确知道的工作应用程序:
shiny app
到目前为止我喜欢它,但我真的更喜欢有一个传单 map ,你可以在其中放大而不是静态 map ,但到目前为止,我在传单包渲染或更新光栅时遇到了很多问题。如果你需要文件,github 仓库就是这个仓库 repository
这是应用程序现在服务器的代码:
library(shiny)
library(raster)
library(rworldmap)
library(rgdal)
library(dplyr)
data("countriesCoarse")
uno <- readRDS("uno.rds")
World <- getData('worldclim', var='bio', res=10)
cities <- readRDS("cities.rds")
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
uno[World[[10]] > ifelse(input$degrees == "Celcius", (input$MaxTempC*10), (((input$MaxTempF-32)*5/9)*10))] <- NA
uno[World[[11]] < ifelse(input$degrees == "Celcius", (input$MinTempC*10), (((input$MinTempF-32)*5/9)*10))] <- NA
uno[World[[1]] < ifelse(input$degrees == "Celcius", min(input$RangeTempC*10), min(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[1]] > ifelse(input$degrees == "Celcius", max(input$RangeTempC*10), max(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[12]] < ifelse(input$degrees == "Celcius", min(input$RangePPC), min(input$RangePPF*25.4))] <- NA
uno[World[[12]] > ifelse(input$degrees == "Celcius", max(input$RangePPC), max(input$RangePPF*25.4))] <- NA
plot(uno, col ="red", legend = FALSE)
plot(countriesCoarse, add = TRUE)
})
output$downloadPlot <- downloadHandler(
filename = function() { paste("WhereToLive", '.png', sep='') },
content = function(file) {
png(file)
uno[World[[10]] > ifelse(input$degrees == "Celcius", (input$MaxTempC*10), (((input$MaxTempF-32)*5/9)*10))] <- NA
uno[World[[11]] < ifelse(input$degrees == "Celcius", (input$MinTempC*10), (((input$MinTempF-32)*5/9)*10))] <- NA
uno[World[[1]] < ifelse(input$degrees == "Celcius", min(input$RangeTempC*10), min(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[1]] > ifelse(input$degrees == "Celcius", max(input$RangeTempC*10), max(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[12]] < ifelse(input$degrees == "Celcius", min(input$RangePPC), min(input$RangePPF*25.4))] <- NA
uno[World[[12]] > ifelse(input$degrees == "Celcius", max(input$RangePPC), max(input$RangePPF*25.4))] <- NA
plot(uno, col ="red", legend = FALSE)
plot(countriesCoarse, add = TRUE)
dev.off()
})
output$visFun <- renderDataTable({
uno[World[[10]] > ifelse(input$degrees == "Celcius", (input$MaxTempC*10), (((input$MaxTempF-32)*5/9)*10))] <- NA
uno[World[[11]] < ifelse(input$degrees == "Celcius", (input$MinTempC*10), (((input$MinTempF-32)*5/9)*10))] <- NA
uno[World[[1]] < ifelse(input$degrees == "Celcius", min(input$RangeTempC*10), min(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[1]] > ifelse(input$degrees == "Celcius", max(input$RangeTempC*10), max(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[12]] < ifelse(input$degrees == "Celcius", min(input$RangePPC), min(input$RangePPF*25.4))] <- NA
uno[World[[12]] > ifelse(input$degrees == "Celcius", max(input$RangePPC), max(input$RangePPF*25.4))] <- NA
cities$exists <- extract(uno, cities[,2:3])
cities <- filter(cities, exists == 1)
cities <- cities[,c(1,4,5,6)]
cities <- filter(cities, pop > min(as.numeric(as.character(input$Population))))
cities <- filter(cities, pop < max(as.numeric(as.character(input$Population))))
cities
})
output$downloadData <- downloadHandler(
filename = function() { paste("cities", '.csv', sep='') },
content = function(file) {
uno[World[[10]] > ifelse(input$degrees == "Celcius", (input$MaxTempC*10), (((input$MaxTempF-32)*5/9)*10))] <- NA
uno[World[[11]] < ifelse(input$degrees == "Celcius", (input$MinTempC*10), (((input$MinTempF-32)*5/9)*10))] <- NA
uno[World[[1]] < ifelse(input$degrees == "Celcius", min(input$RangeTempC*10), min(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[1]] > ifelse(input$degrees == "Celcius", max(input$RangeTempC*10), max(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[12]] < ifelse(input$degrees == "Celcius", min(input$RangePPC), min(input$RangePPF*25.4))] <- NA
uno[World[[12]] > ifelse(input$degrees == "Celcius", max(input$RangePPC), max(input$RangePPF*25.4))] <- NA
cities$exists <- extract(uno, cities[,2:3])
cities <- filter(cities, exists == 1)
cities <- filter(cities$pop > min(input$Population))
cities <- filter(cities$pop < max(input$Population))
cities <- cities[,c(1,4,5,6)]
write.csv(cities, file)
}
)
})
library(shiny)
library(raster)
library(rworldmap)
library(rgdal)
data("countriesCoarse")
shinyUI(fluidPage(
titlePanel("Where should you live according to your climate preferences?"),
sidebarLayout(
sidebarPanel(
h3("Select your climate preferences"),
p("Using worldclim database, and knowing your climate prefeneces, you can now using this tool get an idea of where in the world you should live."),
p("Just use the sliders to anwer the simple questions we ask and you will get a map together with a downloadable table of where the climate suits you."),
selectInput(inputId = "degrees", label = "Temp units:", choices =
c("Celcius"= "Celcius",
"Fahrenheit" = "Fahrenheit")),
submitButton("Update View", icon("refresh")),
conditionalPanel(condition = "input.degrees == 'Celcius'",
sliderInput(inputId = "MaxTempC",
label = "What's the average maximum temperature you want to endure during the summer?",
min = 0,
max = 50,
value = 30),
sliderInput(inputId = "MinTempC",
label = "What's the average minimum temperature you want to endure during the winter?",
min = -40,
max = 60,
value = 0),
sliderInput(inputId = "RangeTempC",
label = "What's your prefered temperature range?",
min = -10,
max = 30,
value = c(0, 20)),
sliderInput(inputId = "RangePPC",
label = "What's your prefered precipitation range?",
min = 0,
max = 5000,
value = c(0, 5000))),
conditionalPanel(condition = "input.degrees == 'Fahrenheit'",
sliderInput(inputId = "MaxTempF",
label = "What's the average maximum temperature you want to endure during the summer?",
min = 0,
max = 120,
value = 90),
sliderInput(inputId = "MinTempF",
label = "What's the average minimum temperature you want to endure during the winter?",
min = -40,
max = 60,
value = 32),
sliderInput(inputId = "RangeTempF",
label = "What's your prefered temperature range?",
min = -40,
max = 90,
value = c(32, 70)),
sliderInput(inputId = "RangePPF",
label = "What's your prefered precipitation range?",
min = 0,
max = 200,
value = c(0, 200))),
sliderInput(inputId = "Population",
label = "how big of a town do you want to live in (Population)?",
min = 0,
max = 20000000,
value = c(0, 20000000, by = 1)))
,
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot"),
downloadButton('downloadPlot', 'Download Plot'),
dataTableOutput("visFun"),
downloadButton('downloadData', 'Download Table')
)
)
))
library(shiny)
library(raster)
library(rworldmap)
library(rgdal)
library(dplyr)
library(leaflet)
library(sp)
data("countriesCoarse")
uno <- readRDS("uno.rds")
World <- getData('worldclim', var='bio', res=10)
cities <- readRDS("cities.rds")
shinyServer(function(input, output) {
output$map <- renderLeaflet({
uno[World[[10]] > ifelse(input$degrees == "Celcius", (input$MaxTempC*10), (((input$MaxTempF-32)*5/9)*10))] <- NA
uno[World[[11]] < ifelse(input$degrees == "Celcius", (input$MinTempC*10), (((input$MinTempF-32)*5/9)*10))] <- NA
uno[World[[1]] < ifelse(input$degrees == "Celcius", min(input$RangeTempC*10), min(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[1]] > ifelse(input$degrees == "Celcius", max(input$RangeTempC*10), max(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[12]] < ifelse(input$degrees == "Celcius", min(input$RangePPC), min(input$RangePPF*25.4))] <- NA
uno[World[[12]] > ifelse(input$degrees == "Celcius", max(input$RangePPC), max(input$RangePPF*25.4))] <- NA
l <- leaflet() %>% setView(0, 0, zoom = 1)
l <- l %>% addRasterImage(uno)
l
})
output$downloadPlot <- downloadHandler(
filename = function() { paste("WhereToLive", '.png', sep='') },
content = function(file) {
png(file)
uno[World[[10]] > ifelse(input$degrees == "Celcius", (input$MaxTempC*10), (((input$MaxTempF-32)*5/9)*10))] <- NA
uno[World[[11]] < ifelse(input$degrees == "Celcius", (input$MinTempC*10), (((input$MinTempF-32)*5/9)*10))] <- NA
uno[World[[1]] < ifelse(input$degrees == "Celcius", min(input$RangeTempC*10), min(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[1]] > ifelse(input$degrees == "Celcius", max(input$RangeTempC*10), max(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[12]] < ifelse(input$degrees == "Celcius", min(input$RangePPC), min(input$RangePPF*25.4))] <- NA
uno[World[[12]] > ifelse(input$degrees == "Celcius", max(input$RangePPC), max(input$RangePPF*25.4))] <- NA
plot(uno, col ="red", legend = FALSE)
plot(countriesCoarse, add = TRUE)
dev.off()
})
output$visFun <- renderDataTable({
uno[World[[10]] > ifelse(input$degrees == "Celcius", (input$MaxTempC*10), (((input$MaxTempF-32)*5/9)*10))] <- NA
uno[World[[11]] < ifelse(input$degrees == "Celcius", (input$MinTempC*10), (((input$MinTempF-32)*5/9)*10))] <- NA
uno[World[[1]] < ifelse(input$degrees == "Celcius", min(input$RangeTempC*10), min(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[1]] > ifelse(input$degrees == "Celcius", max(input$RangeTempC*10), max(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[12]] < ifelse(input$degrees == "Celcius", min(input$RangePPC), min(input$RangePPF*25.4))] <- NA
uno[World[[12]] > ifelse(input$degrees == "Celcius", max(input$RangePPC), max(input$RangePPF*25.4))] <- NA
cities$exists <- extract(uno, cities[,2:3])
cities <- filter(cities, exists == 1)
cities <- cities[,c(1,4,5,6)]
cities <- filter(cities, pop > min(as.numeric(as.character(input$Population))))
cities <- filter(cities, pop < max(as.numeric(as.character(input$Population))))
cities
})
output$downloadData <- downloadHandler(
filename = function() { paste("cities", '.csv', sep='') },
content = function(file) {
uno[World[[10]] > ifelse(input$degrees == "Celcius", (input$MaxTempC*10), (((input$MaxTempF-32)*5/9)*10))] <- NA
uno[World[[11]] < ifelse(input$degrees == "Celcius", (input$MinTempC*10), (((input$MinTempF-32)*5/9)*10))] <- NA
uno[World[[1]] < ifelse(input$degrees == "Celcius", min(input$RangeTempC*10), min(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[1]] > ifelse(input$degrees == "Celcius", max(input$RangeTempC*10), max(((input$RangeTempF-32)*5/9)*10))] <- NA
uno[World[[12]] < ifelse(input$degrees == "Celcius", min(input$RangePPC), min(input$RangePPF*25.4))] <- NA
uno[World[[12]] > ifelse(input$degrees == "Celcius", max(input$RangePPC), max(input$RangePPF*25.4))] <- NA
cities$exists <- extract(uno, cities[,2:3])
cities <- filter(cities, exists == 1)
cities <- filter(cities$pop > min(input$Population))
cities <- filter(cities$pop < max(input$Population))
cities <- cities[,c(1,4,5,6)]
write.csv(cities, file)
}
)
})
library(shiny)
library(raster)
library(rworldmap)
library(rgdal)
library(leaflet)
data("countriesCoarse")
shinyUI(fluidPage(
titlePanel("Where should you live according to your climate preferences?"),
sidebarLayout(
sidebarPanel(
h3("Select your climate preferences"),
p("Using worldclim database, and knowing your climate prefeneces, you can now using this tool get an idea of where in the world you should live."),
p("Just use the sliders to anwer the simple questions we ask and you will get a map together with a downloadable table of where the climate suits you."),
selectInput(inputId = "degrees", label = "Temp units:", choices =
c("Celcius"= "Celcius",
"Fahrenheit" = "Fahrenheit")),
submitButton("Update View", icon("refresh")),
conditionalPanel(condition = "input.degrees == 'Celcius'",
sliderInput(inputId = "MaxTempC",
label = "What's the average maximum temperature you want to endure during the summer?",
min = 0,
max = 50,
value = 30),
sliderInput(inputId = "MinTempC",
label = "What's the average minimum temperature you want to endure during the winter?",
min = -40,
max = 60,
value = 0),
sliderInput(inputId = "RangeTempC",
label = "What's your prefered temperature range?",
min = -10,
max = 30,
value = c(0, 20)),
sliderInput(inputId = "RangePPC",
label = "What's your prefered precipitation range?",
min = 0,
max = 5000,
value = c(0, 5000))),
conditionalPanel(condition = "input.degrees == 'Fahrenheit'",
sliderInput(inputId = "MaxTempF",
label = "What's the average maximum temperature you want to endure during the summer?",
min = 0,
max = 120,
value = 90),
sliderInput(inputId = "MinTempF",
label = "What's the average minimum temperature you want to endure during the winter?",
min = -40,
max = 60,
value = 32),
sliderInput(inputId = "RangeTempF",
label = "What's your prefered temperature range?",
min = -40,
max = 90,
value = c(32, 70)),
sliderInput(inputId = "RangePPF",
label = "What's your prefered precipitation range?",
min = 0,
max = 200,
value = c(0, 200))),
sliderInput(inputId = "Population",
label = "how big of a town do you want to live in (Population)?",
min = 0,
max = 20000000,
value = c(0, 20000000, by = 1)))
,
# Show a plot of the generated distribution
mainPanel(
leafletOutput("map", width = "100%", height = "100%"),
downloadButton('downloadPlot', 'Download Plot'),
dataTableOutput("visFun"),
downloadButton('downloadData', 'Download Table')
)
)
))
Listening on http://127.0.0.1:7231
Warning in rgdal::rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[, :
54 projected point(s) not finite
Warning in rgdal::rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[, :
54 projected point(s) not finite
Warning in rgdal::rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[, :
54 projected point(s) not finite
最佳答案
问题是 height
你的情节不能是相对的。
只需将其替换为绝对值即可显示,例如:
leafletOutput("map", width = "100%", height = 400)
关于r - map 不会在带有传单和光栅的 Shiny 应用程序中呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39337259/
我正在尝试使用 R 中的 raster 包从光栅对象中提取轮廓线。 rasterToContour 似乎工作良好并且绘制得很好,但在调查时发现轮廓线被分解成不规则的线段。来自 ?rasterToCon
我有两个光栅对象 > x1 class : RasterLayer dimensions : 36, 72, 2592 (nrow, ncol, ncell) resolution
我已经看到与CUPS库相关的两个文件: OpenPrinting/cups-filters/blob/master/filter/imagetoraster.c OpenPrinting/cups-f
有没有办法确保绘图周围的框与栅格范围完全匹配?在下面的内容中,根据设备的比例,在栅格的上方,下方或左侧和右侧都有一个间隙: require(raster) r = raster() r[]= 1 pl
我有下面的代码,可以将图像保存到我的电脑上。我想将该图像绕其中心(或左下角)旋转 45,90 和 135 度,然后另存为 3 个不同的图像。我怎样才能做到这一点? library(raster) r1
我有热敏打印机 X330,我需要打印和从 android 相机获取图像(位图),但我不能...我总是在打印机中得到符号。 文档中说: 打印光栅位图 十六进制 1D 76 30 m xL xH yL y
我是 python 的初学者,我仍在熟悉它的库,如果这是一个新手问题,我很抱歉。我只想显示 4 个波段(R、G、B、NIR)的图像。我想删除 NIR 并保留其他 3 个。我该怎么做?由于 raster
我知道这似乎是一个奇怪的问题,而且确实如此!但是利用 Windows 已经安装的固定宽度字体(例如:Fixedsys)我会节省很多大小(因为我想让最终的 EXE 尽可能小) 从 Windows 上现有
要求: 保留图形模式 API 仅适用于 2D 对象(尽管这些 2D 对象的 3D 变换很有趣) 跨平台 矢量图形绘制 光栅合成 + 支持不透明蒙版 - 当然是硬件加速... 动画 API 封装大小 -
我还在 SO 的 GIS 部分发布了这个问题。因为我不确定这是否是一个“纯”python 问题,所以我也在这里再次提问。 我想知道是否有人在不使用 ArcGIS 的情况下从栅格获取高程数据有一些经验,
我是一名优秀的程序员,十分优秀!