# \donttest{
if(require(sp, quietly = TRUE)) {
library(sf)
data(meuse, package = "sp")
meuse <- st_as_sf(meuse, coords = c("x", "y"), crs = 28992,
agr = "constant")
# Subsample with a 500m minimum sample spread
sub.meuse <- subsample.distance(meuse, size = 10, d = 500)
plot(st_geometry(meuse), pch=19, main="min dist = 500")
plot(st_geometry(sub.meuse), pch=19, col="red", add=TRUE)
# Check distances
dm <- st_distance(sub.meuse)
diag(dm) <- NA
cat("\n", "Min distance for subsample", min(dm, na.rm=TRUE), "\n")
cat("Max distance for subsample", max(dm, na.rm=TRUE), "\n")
} else {
cat("Please install sp package to run example", "\n")
}
# }
Run the code above in your browser using DataLab