Interface between sp and bnd format

0th

Percentile

Convert sp and bnd format into each other

Convert geographical information objects of class "SpatialPolygons" (or specializations) from R-package sp to objects of class "bnd" from R-package R2BayesX and vice versa.

Keywords
spatial
Usage
sp2bnd(spObject, regionNames, height2width, epsilon)
bnd2sp(bndObject)
Arguments
spObject

object of class "SpatialPolygons" (or specializations).

regionNames

character vector of region names (parallel to the Polygons list in spObject), defaults to the IDs.

height2width

ratio of total height to width, defaults to the bounding box values.

epsilon

how much can two polygons differ (in maximum squared Euclidean distance) and still match each other?, defaults to machine precision.

bndObject

object of class "bnd".

Value

Equivalent object in the other format.

See Also

nb2gra, gra2nb for conversion between the neighborhood structure formats and read.bnd, write.bnd for the interface to the R2BayesX files.

Aliases
  • sp2bnd
  • bnd2sp
Examples
# NOT RUN {
## bnd to sp:
file <- file.path(find.package("R2BayesX"), "examples", "Germany.bnd")
germany <- read.bnd(file)
spGermany <- bnd2sp(germany)

## plot the result together with the neighborhood graph
if(requireNamespace("spdep")) {
  library("spdep")
  plot(spGermany)
  nbGermany <- poly2nb(spGermany)
  plot(nbGermany, coords = coordinates(spGermany), add = TRUE)

  ## example with one region inside another
  spExample <- spGermany[c("7231", "7235"), ]
  plot(spExample)
  plot(poly2nb(spExample), coords = coordinates(spExample), add = TRUE)

  ## now back from sp to bnd:
  bndGermany <- sp2bnd(spGermany)
  plotmap(bndGermany)

  ## compare names and number of polygons
  stopifnot(
    identical(names(bndGermany), names(germany)),
    identical(length(bndGermany), length(germany))
  )
}
# }
Documentation reproduced from package R2BayesX, version 1.1-1, License: GPL-2 | GPL-3

Community examples

Looks like there are no examples yet.