shape.H: Creating a Neighborhood Matrix for Areal Data from a...

View source: R/shape.H.R

shape.HR Documentation

Creating a Neighborhood Matrix for Areal Data from a Shapefile

Description

Takes a path to a shape file and creates a neighborhood matrix. This neighborhood matrix can be used with the objective ICAR model \insertCiteKeefe_2018ref.ICAR.

Usage

shape.H(shape.file)

Arguments

shape.file

File path to a shapefile.

Value

A list containing a neighborhood matrix and the SpatialPolygonsDataFrame object corresponding to the shape file.

H

A neighborhood matrix.

map

SpatialPolygonsDataFrame object from the provided shapefile.

Author(s)

Erica M. Porter, Matthew J. Keefe, Christopher T. Franck, and Marco A.R. Ferreira

Examples

#### Load extra libraries
library(sp)
library(sf)

### Read in a shapefile of the contiguous U.S. from package data
system.path <- system.file("extdata", "us.shape48.shp", package = "ref.ICAR", mustWork = TRUE)
shp.layer <- gsub('.shp','',basename(system.path))
shp.path <- dirname(system.path)
us.shape48 <- st_read(dsn = path.expand(shp.path), layer = shp.layer)

shp.data <- shape.H(system.path)
names(shp.data)

ref.ICAR documentation built on Aug. 22, 2023, 9:12 a.m.