An S4 class that contains all information on a spatial network which is composed by a set of nodes that are linked by some neighborhood relation. The class is constructed by the spflow_network() function.

# S4 method for spflow_network
dat(object)

# S4 method for spflow_network
dat(
  object,
  node_key_column,
  node_coord_columns,
  derive_coordinates = FALSE,
  prefer_lonlat = TRUE
) <- value

# S4 method for spflow_network
id(object)

# S4 method for spflow_network
id(object) <- value

# S4 method for spflow_network
neighborhood(object)

# S4 method for spflow_network
neighborhood(object) <- value

# S4 method for spflow_network
nnodes(object)

# S4 method for spflow_network
update_dat(object, new_dat)

Arguments

object

A spflow_network-class

value

An object to replace the existing id/data/neighborhood

node_key_column

A character indicating the column containing the identifiers for the nodes

node_coord_columns

A character indicating the columns that represent the coordinates of the nodes. For example c("LON", "LAT").

derive_coordinates

A logical indicating whether there should be an attempt to infer the coordinates from the node_data.

prefer_lonlat

A logical indicating whether the coordinates should be transformed to longitude and latitude.

new_dat

A data.frame

Details

The data on each node is stored in a data.frame, where each node must be uniquely identified by a key. The neighborhood relations are described by a matrix that satisfies the usual assumptions of the spatial weight matrix in spatial econometric models. In most cases each node will only neighbor to a few others, in which case the neighborhood matrix is represented as a sparseMatrix(). Function to create spatial neighborhood matrices can be found in the spdep package.

Slots

id_net

A character that serves as an identifier for the set of nodes

node_data

A data.frame that contains all information describing the nodes

node_neighborhood

A matrix that describes the neighborhood relations of the nodes

Examples

## access the data describing the nodes
new_dat <- dat(germany_net)

# access the id of the network
germany_net2 <- germany_net
id(germany_net2)
#> [1] "ge"
id(germany_net2) <- "Germany"

# access the neighborhood matrix of the nodes
neighborhood(germany_net)
#> 16 x 16 sparse Matrix of class "dgCMatrix"
#>                                                                             
#> SH .   0.5000000 0.5000000 .         .         .         .         .        
#> HH 0.2 .         0.2000000 0.2000000 0.2000000 0.2000000 .         .        
#> MV 0.2 0.2000000 .         .         0.2000000 0.2000000 0.2000000 .        
#> NW .   0.2500000 .         .         0.2500000 .         .         0.2500000
#> HB .   0.1428571 0.1428571 0.1428571 .         0.1428571 .         0.1428571
#> BB .   0.1428571 0.1428571 .         0.1428571 .         0.1428571 .        
#> BE .   .         0.2500000 .         .         0.2500000 .         .        
#> RP .   .         .         0.2000000 0.2000000 .         .         .        
#> NI .   .         .         0.1250000 0.1250000 0.1250000 .         0.1250000
#> ST .   .         .         .         0.1428571 0.1428571 0.1428571 .        
#> SN .   .         .         .         .         0.2500000 0.2500000 .        
#> SL .   .         .         .         .         .         .         0.2500000
#> HE .   .         .         .         .         .         .         0.1428571
#> TH .   .         .         .         .         .         .         .        
#> BW .   .         .         .         .         .         .         .        
#> BY .   .         .         .         .         .         .         .        
#>                                                                         
#> SH .         .         .         .         .         .         .        
#> HH .         .         .         .         .         .         .        
#> MV .         .         .         .         .         .         .        
#> NW 0.2500000 .         .         .         .         .         .        
#> HB 0.1428571 0.1428571 .         .         .         .         .        
#> BB 0.1428571 0.1428571 0.1428571 .         .         .         .        
#> BE .         0.2500000 0.2500000 .         .         .         .        
#> RP 0.2000000 .         .         0.2000000 0.2000000 .         .        
#> NI .         0.1250000 .         0.1250000 0.1250000 0.1250000 .        
#> ST 0.1428571 .         0.1428571 .         0.1428571 0.1428571 .        
#> SN .         0.2500000 .         .         .         0.2500000 .        
#> SL 0.2500000 .         .         .         0.2500000 .         0.2500000
#> HE 0.1428571 0.1428571 .         0.1428571 .         0.1428571 0.1428571
#> TH 0.1666667 0.1666667 0.1666667 .         0.1666667 .         0.1666667
#> BW .         .         .         0.2500000 0.2500000 0.2500000 .        
#> BY .         .         .         .         0.3333333 0.3333333 0.3333333
#>             
#> SH .        
#> HH .        
#> MV .        
#> NW .        
#> HB .        
#> BB .        
#> BE .        
#> RP .        
#> NI .        
#> ST .        
#> SN .        
#> SL .        
#> HE 0.1428571
#> TH 0.1666667
#> BW 0.2500000
#> BY .        

# access the number of nodes inside the network
nnodes(germany_net)
#> [1] 16