make_grid: Make grid

View source: R/make_grid.R

make_gridR Documentation

Make grid

Description

Make grid

Usage

make_grid(
  x,
  hexagonal = TRUE,
  cell_area,
  clip = FALSE,
  grid_boundary = FALSE,
  tolerance = NULL
)

Arguments

x

Object of class sf, sfc, sfg, SpatialPolygons

hexagonal

logical. If TRUE then the geometry grid will be hexagonal otherwise it will be square.

cell_area

numeric. Grid area in the CRS units of object x.

clip

logical. If TRUE, the new grid will be clipped to the x geometry. The operation time will be longer the greater the number of vertices in the polygon of the region. If it is a region with many vertices use the parameter tolerance.

grid_boundary

logical. If TRUE, the "hexagons" or "squares" in the boundaries (i.e, that are not completely within the geometry x) will be removed.

tolerance

numeric. Reduces the number of vertices in the x polygon by simplifying its shape (see, st_simplify). It must be specified in meters

Value

Returns a class object sf with a hexagonal or square polygon grid.

Examples

## Not run: 
library(Makurhini)
library(sf)
data("study_area", package = "Makurhini")
test <- make_grid(x = study_area, hexagonal = TRUE,
                  cell_area = unit_convert(10, "km2", "m2"))
plot(test)
test <- make_grid(x = study_area, hexagonal = TRUE,
                  cell_area = unit_convert(10, "km2", "m2"),
                  clip = TRUE)
plot(test)
test <- make_grid2(x = study_area, hexagonal = TRUE,
                   cell_area = unit_convert(10, "km2", "m2"),
                   grid_boundary = TRUE)
plot(st_geometry(study_area)); plot(test, add = T)

## End(Not run)

connectscape/Makurhini documentation built on Jan. 12, 2025, 8:16 p.m.