【问题标题】:Polygon background in leaflet传单中的多边形背景
【发布时间】:2019-10-10 08:10:25
【问题描述】:

有没有办法(在 R 中最好不要下载任何额外的数据集)如何在传单中制作多边形(或更明显的国家边界)

使用简单的代码

m = leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
addCircles(lat=15,lng=18, radius = 300, color = "blue")

m

【问题讨论】:

  • 你的意思是像addPolygons()
  • 是的,但是我在哪里可以找到多边形数据,比如说整个欧洲?

标签: r maps r-leaflet


【解决方案1】:

spData-package 中有一个世界 sf-dataset。

library(leaflet)
library(sf)
library(spData)

leaflet() %>% 
addProviderTiles("CartoDB.Positron") %>% 
addPolygons(data = world[world$continent == "Europe",], weight = 1)

如果您只想要国家/地区的轮廓,请使用:addPolylines()

【讨论】:

  • 非常感谢 zou 我采纳了你的建议并稍微改写了一下,所以多边形只在全国范围内addPolygons(data = world, col = 'black', fillOpacity = 0.0001, smoothFactor = 0.0001, weight = 2)
猜你喜欢
  • 1970-01-01
  • 2012-07-15
  • 1970-01-01
  • 2018-08-04
  • 2021-10-02
  • 2019-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多