R编程:在LeafLet中使用ISO国家代码

时间:2016-07-13 09:38:15

标签: r shiny rworldmap leaflet.draw

我正致力于创建客户端信息中心。我有客户的ISO国家代码,我也使用rworldmap包在地图上绘制了相同的代码,但用户界面不是很好。

所以,我想使用传单包。如何在创建地图时使用这些ISO国家/地区代码ALPHA 2。

谢谢!

1 个答案:

答案 0 :(得分:0)

Leaflet不接受ISO Alpa2代码,而是接受ISO Alpha3代码。经过几乎所有地方,我尝试了这个,它解决了我的问题。

output$myMapOne = renderPlotly({
       height  = 1000 
       units="px"
       clientName = input$clientSelector
       conWiseSub = subset(conData, conData$GCA_CSTMR_DS == clientName)
       defOne = aggregate(CNT ~ CODE, conWiseSub, sum)
       d = defOne$CODE
       e = defOne$CNT

       # light grey boundaries
       l <- list(color = toRGB("grey"), width = 0.5)

       # specify map projection/options
       g <- list(
         showframe = TRUE,
         showcoastlines = FALSE,showland = TRUE,showcountries = TRUE,
         countrycolor = toRGB("white"),
         landcolor = toRGB("grey85"),
         projection = list(type = 'Mercator', scale =1)
       )

       plot_ly(defOne, z = e, text = d,locations = d,  type = 'choropleth',
               color = e, colors = 'PuBu', marker = list(line = l), colorbar = list(title = "SOI Distribution")
              ) %>%
         layout( geo = g,title= paste("Region Wise SOI Distribution of", clientName , sep = " "))
     })

Click Here to View the Map Created By the Code

希望这会有所帮助!!