R中的Queen和Rook边界网络矩阵

时间:2019-10-27 18:14:33

标签: r spatial spatial-data

如何根据国家(连续性或女王性)连续性创建空间权重矩阵?

我先了解功能poly2nb,然后了解nb2listw,但是使用ggplot对象巫婆应具有多边形信息,不适用于所列国家/地区。

require(maps)
require(viridis)
library(ggplot2)
library(spdep)
library(RColorBrewer)
library(wesanderson)

some.eu.countries <- c(
  "Portugal", "Spain", "France", "Switzerland", "Germany",
  "Austria", "Belgium", "UK", "Netherlands",
  "Denmark", "Poland", "Italy",
  "Croatia", "Slovenia", "Hungary", "Slovakia",
  "Czech republic", "Ukraine", "Ukraine", "Finland", "Belarus", "Norway", 
  "Sweden", "Finland", "Estonia", "Latvia", "Lithuania" ,"Moldova", "Romania", 
  "Bulgaria", "Macedonia", "Greece"
)
# Retrievethe map data

map_data("europe")

some.eu.maps <- map_data("world", region = some.eu.countries) 

g = ggplot(some.eu.maps, aes(x = long, y = lat, group = group)) +
  geom_polygon(fill="lightgray", colour = "white") 
print(g)

然后创建权重矩阵:

# Spatial weights based on the border (Rook and Queen)
Border_Weight <- poly2nb(g)
summary(Border_Weight)
S<-nb2listw(Border_Weight)

我想念什么?

0 个答案:

没有答案