neighbormatrix: Compute a Neighborhood Matrix from Spatial Polygons

Description Usage Arguments See Also Examples

Description

The function takes a SpatialPolygonsDataFrame and computes the neighbor penalty matrix that can be used to fit a Markov random field, e.g., using the smooth constructor smooth.construct.mrf.smooth.spec.

Usage

1
2
3
4
5
6
## Compute the neighborhood matrix.
neighbormatrix(x, type = c("boundary", "dist", "delaunay", "knear"),
  k = 1, id = NULL, nb = FALSE, names = NULL, ...)

## Plot neighborhood structure.
plotneighbors(x, add = FALSE, ...)

Arguments

x

An object of class "SpatialPolygons" or "SpatialPolygonsDataFrame".

type

Which type of neighborhood structure should be used, "boundary" uses poly2nb, "dist" uses function dnearneigh, "delaunay" uses function tri2nb and option "knear" applies function knn2nb.

k

For type = "knear", specifies number of nearest neighbors.

id

An identifier variable for which the penalty matrix should be computed.

nb

Should only the neighborhood object be returned.

names

Specifies the column where the regions names are provided in the data slot in the "SpatialPolygonsDataFrame"

add

Should the neighborhood structure be added to an existing plot?

...

Arguments to be passed to function poly2nb, dnearneigh, tri2nb or knn2nb.

See Also

smooth.construct.mrf.smooth.spec, dnearneigh, tri2nb, knn2nb.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data("LondonFire")

## Compute polygon boundary based
## neighborhood matrix.
nm <- neighbormatrix(LondonBoroughs)
print(nm)

## Plot neighborhood structures.
plotneighbors(LondonBoroughs)
plotneighbors(LondonBoroughs, type = "delaunay")
plotneighbors(LondonBoroughs, type = "dist", d1 = 0, d2 = 0.15)


Search within the bamlss package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.