Created
August 10, 2012 15:38
-
-
Save datagistips/3315103 to your computer and use it in GitHub Desktop.
Neighbord relationships below a certain distance threshold
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rgdal) | |
library(spdep) | |
pol <- readOGR(".", "buildings") # read the data using rgdal | |
nb <- poly2nb(pol, snap=50) # create a graph. Two buildings are connected if they are 50 meters apart from one another. | |
pol$nNeigh <- card(nb) # card(nb) gives the neighbor counts | |
pol$neighGroup <- n.comp.nb(nb)$comp.id # n.comp.nb contains the informations about the disconnected compontents |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment