Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.7k views
in Technique[技术] by (71.8m points)

r - Create a spatial weight matrix but without shp file

I have a data about municipalities in France. And I want to create a spatial weight matrix using this data. But the problem is this is not a .shp file data. It is .csv Below is the link to the data file. This file has more than 35000 municipalities. For simplicity, I will just assume that there are only 10 municipalities. So the data will be of the form:-

data <- data.frame(insee=c("01001", "01002", "01004", "01005", "01006"),
                  insee_voisins=c("01002|01004|01005", "01001|01005", "01001|01006",
                                  "01001|01002|01006", "01004|01006"))

Assuming that the above data creates a proper spatial pattern, how make its spatial weights matrix which will be of the following form:-

       [, 1]  [, 2]  [, 3]  [, 4]  [, 5]
[1, ]    0      1      1      1      0
[2, ]    1      0      0      1      0
[3, ]    1      0      0      0      1
[4, ]    1      1      0      0      1
[5, ]    0      0      1      1      0

Please keep in mind that the actual data has more than 35000 municipalities. So if you have a memory and speed efficient solution, it would be better.

Thanks in advance.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...