library(sf)
data(ralu.site, package="GeNetIt")
# Saturated spatial graph
sat.graph <- knn.graph(ralu.site, row.names=ralu.site$SiteName)
head(sat.graph)
# Distanced constrained spatial graph
dist.graph <- knn.graph(ralu.site, row.names=ralu.site$SiteName,
max.dist = 5000)
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,2))
plot(st_geometry(sat.graph), col="grey")
points(st_coordinates(ralu.site), col="red", pch=20, cex=1.5)
box()
title("Saturated graph")
plot(st_geometry(dist.graph), col="grey")
points(st_coordinates(ralu.site), col="red", pch=20, cex=1.5)
box()
title("Distance constrained graph")
par(opar)
Run the code above in your browser using DataLab