Skip to contents

A network of neighbouring map regions including connections due to bridges airports or ferry links, defined in the bridges input.

Usage

createNeighbourNetwork(
  shape,
  idVar = "code",
  bridges = arear::ukconnections,
  queen = FALSE,
  ...
)

Arguments

shape

a `sf` object

idVar

the column containing the coded identifier of the map

bridges

a df with the following columns: `name` `start.lat` `start.long` `end.lat` `end.long` defining connections between non touching shapes (e.g. bridges / ferries / etc.)

queen

- include neighbouring areas that only touch at corners, defaults to false.

...

Named arguments passed on to .cached

.nocache

an option to defeat the caching which can be set globally as options("cache.disable"=TRUE)

.stale

the length of time in days to keep cached data before considering it as stale. can also be set by options("cache.stale")

Value

an edge list of ids with from and to columns

Examples


edges = createNeighbourNetwork(
  shape = arear::testdata$grid11x11,
  idVar = "id"
)
#> although coordinates are longitude/latitude, st_contains assumes that they are
#> planar
#> although coordinates are longitude/latitude, st_contains assumes that they are
#> planar
#> although coordinates are longitude/latitude, st_intersects assumes that they
#> are planar

# in regular grid each cell has 4 neighbours except the edges and corners
# we loose 1 per edge

nrow(edges) == 11*11*4-4*11
#> [1] TRUE

queens = createNeighbourNetwork(
  shape = arear::testdata$grid11x11,
  idVar = "id",
  queen = TRUE
)
#> although coordinates are longitude/latitude, st_contains assumes that they are
#> planar
#> although coordinates are longitude/latitude, st_contains assumes that they are
#> planar
#> although coordinates are longitude/latitude, st_intersects assumes that they
#> are planar

# each cell has 8 queen neighbours
# except edge pieces which have 3 less, and corners which have 5 less.
nrow(queens) == 11*11*8 - 4*9*3 - 4*5
#> [1] TRUE