data(forestgap)
patchsizes(forestgap[[5]]) # Use a single matrix
# Compute the average patch size of each matrix
list_patches <- patchsizes(forestgap) # get the patch size for each matrix
print( sapply(list_patches, mean)) # print the average patch size
# Example with 8-way neighborhood
patchsizes(forestgap[[5]], nbmask = "moore")
# Same neighborhood as above, but specified in matrix form
moore_nb <- matrix(c(1, 1, 1,
1, 0, 1,
1, 1, 1),
nrow = 3, ncol = 3, byrow = TRUE)
patchsizes(forestgap[[5]], nbmask = moore_nb)
Run the code above in your browser using DataLab