我有德国邮政编码的多边形形状数据。对于那些邮政编码多边形,我喜欢计算各种最近邻度量。我已经看到了使用sp
包的过程(使用coordinates()
,如knearneigh(coordinates(GER), k = 4)
)。我在R中选择了sf
空间对象,但对如何在这里实现邻居感到困惑。谢谢你
library(sf)
library(dplyr)
library(leaflet)
URL <- "https://downloads.suche-postleitzahl.org/v2/public/plz-5stellig.shp.zip"
# use GDAL virtual file systems to load zipped shapefile from remote url
GER_postcode <- paste0("/vsizip//vsicurl/", URL) %>% read_sf()
# country outline from giscoR
GER_outline <- giscoR::gisco_get_countries(country = "DE")
# subsample
GER_postcode_subsample <- GER_postcode %>% filter(substr(plz, 1, 1) %in% c(0, 1, 7))
# k nearest neighbours for sf dataframe
字符串
1条答案
按热度按时间rvpgvaaj1#
我在包含speaking函数
poly2nb()
的spdep
包中找到了答案。不知道为什么我没有早点发现。字符串