【发布时间】:2021-08-04 02:47:44
【问题描述】:
我正在尝试在德国绘制具有特殊边界(投票区)的联邦国家地图:
install.packages("OpenStreetMap")
install.packages("sf")
install.packages("osmdata")
install.packages("tmap")
library(OpenStreetMap)
library(sf)
library(osmdata)
library(tmap)
## I use this because the other overpass server didnt work that well
set_overpass_url("https://overpass-api.de/api/interpreter")
##open the map of "baden-württemberg" and get the right boundaries, timeout is increased because the map is big and it sometimes timed out
boundaries <- opq(bbox = getbb("baden-württemberg"), timeout = 900) %>%
add_osm_feature(key = 'admin_level', value = '6') %>%
add_osm_feature(key = "boundary", value = "administrative") %>%
osmdata_sf() %>% unique_osmdata()
qtm(boundaries$osm_multipolygons)
我明白了
Error in do.call(rbind, x) : variable names are limited to 10000 bytes
它应该大致如下所示:
boundaries <- opq(bbox = 'Brussels, Belgium') %>%
add_osm_feature(key = 'admin_level', value = '8') %>%
osmdata_sf %>% unique_osmdata
municipalities <- boundaries$osm_multipolygons
qtm(municipalities)
结果图: [
【问题讨论】:
-
对于非核心软件包,始终至少包含
library调用。更好的是包含一个条件,当它(它们)被相当少使用时安装包,然后加载包。 -
感谢您的建议,我添加了 install.packages() 和 library() 调用!
标签: r openstreetmap tmap