Aliases: st_make_grid
Keywords:
### ** Examples plot(st_make_grid(what = "centers"), axes = TRUE) plot(st_make_grid(what = "corners"), add = TRUE, col = 'green', pch=3)
sfc = st_sfc(st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,0))))) plot(st_make_grid(sfc, cellsize = .1, square = FALSE)) plot(sfc, add = TRUE)
# non-default offset: plot(st_make_grid(sfc, cellsize = .1, square = FALSE, offset = c(0, .05 / (sqrt(3)/2)))) plot(sfc, add = TRUE)
nc = st_read(system.file("shape/nc.shp", package="sf"))
Reading layer `nc' from data source `/usr/local/R/4.2/site-library/sf/shape/nc.shp' using driver `ESRI Shapefile' Simple feature collection with 100 features and 14 fields Geometry type: MULTIPOLYGON Dimension: XY Bounding box: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965 Geodetic CRS: NAD27
g = st_make_grid(nc) plot(g) plot(st_geometry(nc), add = TRUE) # g[nc] selects cells that intersect with nc: plot(g[nc], col = '#ff000088', add = TRUE)