我的地图有点麻烦,想知道你们是否有想法。
我正在尝试创建一个显示碳排放量的choropleth贴图,上面覆盖着气泡,显示一种叫做GAIN的东西。但是,尽管每次将气泡添加到Shiny代码中时,我几乎都看不到碳排放量的可视化。 如果我通过在气泡填充之前将气泡颠倒输出$ map的顺序,我会恢复碳排放数据的可视化,但会丢失除3个气泡之外的所有气泡?
版本1.1.453
#Installing Needed Packages to Run
library(leaflet)
library(tmap)
library(RColorBrewer)
library(rgeos)
library(rgdal)
library(shiny)
library(sp)
#Install and Process Data
carbontest <-read.csv("carbontest.csv")
Output.Areas<- readOGR(".", "ne_50m_admin_0_countries")
Meshblocktest <- merge(Output.Areas, carbontest, by.x="SOVEREIGNT", by.y="country_name")
#Carbon Emission Point Data
survey.marks <- read.csv("TESTTEST5.csv")
Survey.Points <- SpatialPointsDataFrame(survey.marks[,2:3], survey.marks,proj4string = CRS("+init=EPSG:4167"))
Survey.Points <- spTransform(Survey.Points, CRS("+init=epsg:4167"))
meshblocktesttransform <- spTransform(Meshblocktest, CRS("+init=epsg:4167"))
#The App
ui <- fluidPage(
mainPanel(
leafletOutput("map")
)
)
server <- function(input, output) {
output$map <- renderLeaflet({
tm <- tm_shape(meshblocktesttransform) +tm_fill("CarbonEmissions", palette = "Reds", style = "quantile") +
tm_shape(Survey.Points) + tm_bubbles(size = "GAIN", col = "GAIN", palette = "BuPu", style = "quantile") +
tmap_leaflet(tm)
})
}
shinyApp(ui, server)