Learn R Programming

bfsMaps (version 1.99.3)

Neighbours: Find All Neighbours of a Regional Object

Description

Finding all directly adjacent neighbours of a regional unit is not trivial. For a list of regional units, this function searches for the corresponding Neighbours and returns the results as a list.

Usage

Neighbours(map, id = NULL)

Value

A list of vectors of ids for the neighbours of each region in the map.

Arguments

map

the name of the map

id

vector of ids for which the Neighbours are to be found. When it's left to NULL (default), the neighbours for all the polygons of the map will be returned.

Author

Andri Signorell <andri@signorell.net>

Examples

Run this code
try( {

nbs <- Neighbours(GetMap("kant.map"), kt_id <- 18)
PlotKant(c(kt_id, nbs), col=c("red", rep("green", length(nbs))) )

# works as well for communities and for vector of ids
nbs <- Neighbours(GetMap("polg.map"), polg_id <- c(3851, 3352))
PlotPolg(c(polg_id, unlist(nbs)),
         col=c(rep("red", 2), rep("green", length(unlist(nbs)))))

})

Run the code above in your browser using DataLab