I'm trying to construct neighbours list from polygon list for Lower Layer Super Output Areas (LSOA) in London. I got my shapefiles from the London Datastore, by downloading here: https://data.london.gov.uk/dataset/statistical-gis-boundary-files-london
When I read in the 2004 shapefile (LSOA_2004_London_Low_Resolution.shp
) it works perfectly:
ldn <- st_read("statistical-gis-boundaries-london/ESRI/LSOA_2004_London_Low_Resolution.shp")
#make into sp
ldn_sp <- as(ldn, "Spatial")
#create a list of neighbours using the Queen criteria (default, if you want rook chage to queen = FALSE)
w <- poly2nb(ldn_sp)
plot(ldn_sp, border = "grey60")
plot(w, coordinates(ldn_sp), pch = 19, cex = 0.6, add = TRUE)
When I read in the 2011 shapefile (LSOA_2011_London_gen_MHW.shp
) however it seems to think that most of the LSOAs don't have neighbours.
When I use the 2011 one with the same code, I get this:
ldn <- st_read("statistical-gis-boundaries-london/ESRI/LSOA_2011_London_gen_MHW.shp")
ldn_sp <- as(ldn, "Spatial")
w <- poly2nb(ldn_sp)
plot(ldn_sp, border = "grey60")
plot(w, coordinates(ldn_sp), pch = 19, cex = 0.6, add = TRUE)
Does anyone have any ideas what I'm doing wrong? LSOAs which clearly should have neighbours show up with 0 links. I have no idea why...!