Creates a spatial weights matrix by multiplying an adjacency (connectivity)
matrix (see connectivity_matrix()
) and an edges weights matrix (see
edges_weights_matrix()
). Resulting spatial weights equal to 0 will be
replaced by 4 x max(w)
, where max(w)
is the maximal weight in the
matrix.
spatial_weights_matrix(x, y)
an adjacency matrix
of dimensions n x n
, where n
is the
number of nodes (sites). The output of connectivity_matrix()
.
an edges weight matrix
of dimensions n x n
, where n
is the
number of nodes (sites). The output of edges_weights_matrix()
.
A spatial weights matrix
of dimensions n x n
, where n
is the
number of nodes (sites).
# Import Adour sites ----
path_to_file <- system.file("extdata", "adour_survey_sampling.csv",
package = "chessboard")
adour_sites <- read.csv(path_to_file)
# Select the 15 first sites ----
adour_sites <- adour_sites[1:15, ]
# Create node labels ----
adour_sites <- create_node_labels(adour_sites,
location = "location",
transect = "transect",
quadrat = "quadrat")
# Create edges based on the pawn move (directed network) ----
adour_edges <- create_edge_list(adour_sites, method = "pawn",
directed = TRUE)
# Get connectivity matrix ----
adour_adjacency <- connectivity_matrix(adour_edges)
# Convert sites to sf object (POINTS) ----
adour_sites_sf <- sf::st_as_sf(adour_sites,
coords = c("longitude", "latitude"),
crs = "epsg:2154")
# Compute distances between pairs of sites along the Adour river ----
adour_dists <- distance_euclidean(adour_sites_sf)
# Create Edges weights matrix ----
adour_weights <- edges_weights_matrix(adour_dists)
# Create Spatial weights matrix ----
spatial_weights_matrix(adour_adjacency, adour_weights)
#> 1-1 1-2 1-3 1-4 1-5 2-1 2-2
#> 1-1 10001.88 2500.469 10001.876 10001.876 10001.876 10001.88 10001.876
#> 1-2 10001.88 10001.876 2500.469 10001.876 10001.876 10001.88 10001.876
#> 1-3 10001.88 10001.876 10001.876 2500.469 10001.876 10001.88 10001.876
#> 1-4 10001.88 10001.876 10001.876 10001.876 2500.469 10001.88 10001.876
#> 1-5 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 10001.876
#> 2-1 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 2500.469
#> 2-2 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 10001.876
#> 2-3 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 10001.876
#> 2-4 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 10001.876
#> 2-5 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 10001.876
#> 3-1 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 10001.876
#> 3-2 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 10001.876
#> 3-3 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 10001.876
#> 3-4 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 10001.876
#> 3-5 10001.88 10001.876 10001.876 10001.876 10001.876 10001.88 10001.876
#> 2-3 2-4 2-5 3-1 3-2 3-3 3-4
#> 1-1 10001.876 10001.876 10001.876 10001.88 10001.876 10001.876 10001.876
#> 1-2 10001.876 10001.876 10001.876 10001.88 10001.876 10001.876 10001.876
#> 1-3 10001.876 10001.876 10001.876 10001.88 10001.876 10001.876 10001.876
#> 1-4 10001.876 10001.876 10001.876 10001.88 10001.876 10001.876 10001.876
#> 1-5 10001.876 10001.876 10001.876 10001.88 10001.876 10001.876 10001.876
#> 2-1 10001.876 10001.876 10001.876 10001.88 10001.876 10001.876 10001.876
#> 2-2 2500.469 10001.876 10001.876 10001.88 10001.876 10001.876 10001.876
#> 2-3 10001.876 2500.469 10001.876 10001.88 10001.876 10001.876 10001.876
#> 2-4 10001.876 10001.876 2500.469 10001.88 10001.876 10001.876 10001.876
#> 2-5 10001.876 10001.876 10001.876 10001.88 10001.876 10001.876 10001.876
#> 3-1 10001.876 10001.876 10001.876 10001.88 2500.469 10001.876 10001.876
#> 3-2 10001.876 10001.876 10001.876 10001.88 10001.876 2500.469 10001.876
#> 3-3 10001.876 10001.876 10001.876 10001.88 10001.876 10001.876 2500.469
#> 3-4 10001.876 10001.876 10001.876 10001.88 10001.876 10001.876 10001.876
#> 3-5 10001.876 10001.876 10001.876 10001.88 10001.876 10001.876 10001.876
#> 3-5
#> 1-1 10001.876
#> 1-2 10001.876
#> 1-3 10001.876
#> 1-4 10001.876
#> 1-5 10001.876
#> 2-1 10001.876
#> 2-2 10001.876
#> 2-3 10001.876
#> 2-4 10001.876
#> 2-5 10001.876
#> 3-1 10001.876
#> 3-2 10001.876
#> 3-3 10001.876
#> 3-4 2500.469
#> 3-5 10001.876