library(sf)
# Example shapefile data
nc <- st_read(system.file("shape/nc.shp", package="sf"))
# Create grid with 10 km spatial resolution
grid <- create_grid(nc, spat_res = 10)
# Plot the grid
plot(st_geometry(nc))
plot(grid, add = TRUE, col = 'red')
Run the code above in your browser using DataLab