# Create an sfc object from a data frame of two columns
x <- data.frame(
lon = c(5, 10, 15, 20, 5, 10, 15, 20),
lat = c(5, 5, 5, 5, 10, 10, 10, 10)
)
pts2poly_centroids(x, 2.5, crs = 4326)
# Create an sf object from a data frame of more than two columns
x <- data.frame(
lon = c(5, 10, 15, 20, 5, 10, 15, 20),
lat = c(5, 5, 5, 5, 10, 10, 10, 10),
sdm.pred = runif(8),
sdm.pred2 = runif(8)
)
pts2poly_centroids(x, 2.5, crs = 4326, agr = "constant")
Run the code above in your browser using DataLab