hexGrid {spBayes}R Documentation

Generates a hexagon tessellation within a bounding box

Description

This function generates a hexagon tessellation within a bounding box.

Usage

 hexGrid(nodes.per.layer, b.box, ...)

Arguments

nodes.per.layer the number of hexagons from min.x to max.x at min.y.
b.box the domain's bounding box defined with a vector of length four and elements ordered min.x, min.y, max.x, max.y.
... currently no additional arguments.

Value

A list with the following tags:

hx.hy a vector of length two that holds the height and width, respectively, between hexagon centroids.
layers the number of hexagon layers within the domain.
nodes.per.layer the number of hexagons from min.x to max.x at min.y.
hex.centroids an nx2 matrix with rows corresponding the the x and y coordinates of the n hexagons within the domain.
hex.polygons a list with 6x2 matrices which hold the hexagons' x and y vertices coordinates.

Author(s)

Andrew O. Finley finleya@msu.edu,
Sudipto Banerjee baner009@umn.edu

Examples

## Not run: 

##Define the bounding box and make the call
b.box <- c(0,0,10,10)

out <- hexGrid(20, b.box)

##Plot using lapply
par(mfrow=c(1,2))
    
plot(out$hex.centroids, pch=19, cex=0.5,
     ylab="Northing", xlab="Easting")
lapply(out$hex.polygons, polygon, col="blue")

##Now color hexagons based on value
my.col.ramp <- function(z){
  zlim <- range(z)
  zlen <- zlim[2]-zlim[1]+1
  colorlut <- heat.colors(as.integer(zlen))
  col <- colorlut[z-zlim[1]+1]
  col
}

n <- nrow(out$hex.centroids)
col <- my.col.ramp(rnorm(n))

plot(out$hex.centroids, typ="n", ylab="", xlab="Easting")
for(i in 1:n){
  polygon(out$hex.polygons[[i]], col=col[i], border=col[i])
}

## End(Not run)
  

[Package spBayes version 0.1-2 Index]