create_grid: Create grid

create_grid_rectangularR Documentation

Create grid

Description

Create grid of equally spaced rectangles or hexagons. The distance between centre points in both x and y dimension is equal to cell_size. The function is effectively a wrapper around st_make_grid with a little bit of preprocessing including generation of grid only inside st_convex_hull.

Usage

create_grid_rectangular(
  geometry,
  cell_size,
  side_offset = 0,
  only_inside = FALSE
)

create_grid_hexagonal(
  geometry,
  cell_size,
  side_offset = 0,
  only_inside = FALSE
)

Arguments

geometry

sf data.frame containing geometry which should be cover by the grid.

cell_size

numeric specifying the distance for equally spaced centers of polygons (rectangular or hexagonal).

side_offset

numeric specifying the side offset, distance added to the convex hull of input geometry to generate grid for KDE. Good estimate is usually the same value as band width of KDE.

only_inside

logical specifying if the grid cells should be generated only inside of the geometry. Default value is FALSE.

Value

sf data.frame.

Functions

  • create_grid_rectangular(): Create rectangular grid

  • create_grid_hexagonal(): Create hexagonal grid

Examples

library(sf)
nc <- st_read(system.file("shape/nc.shp", package = "sf")) %>% st_transform(32031)
grid <- create_grid_hexagonal(nc, cell_size = 100000)
grid <- create_grid_rectangular(nc, cell_size = 100000, only_inside = TRUE)


SpatialKDE documentation built on March 7, 2023, 6:25 p.m.