gpat_st_make_grid: Grid polygon creator (without a header)

View source: R/gpat_create_grid.R

gpat_st_make_gridR Documentation

Grid polygon creator (without a header)

Description

Creates a polygon of a GeoPAT grid based on a given parameters

Usage

gpat_st_make_grid(x, n = c(10, 10), brick = FALSE)

Arguments

x

An object of class sf or sfc

n

An integer of length 1 or 2, number of grid cells in x and y direction (columns, rows)

brick

TRUE/FALSE; should a new grid polygon have a brick topology

Value

sf

References

Based on the st_make_grid function from the sf package

Examples

## Not run: 
library(sf)
nc = st_read(system.file("shape/nc.shp", package="sf"))

my_grid = gpat_st_make_grid(nc)
my_grid$id = 1:100

grid_centroids = st_centroid(my_grid) %>%
  st_coordinates(grid_centroids) %>%
  as_data_frame() %>%
  mutate(id = 1:100)

ggplot() +
  geom_sf(data = my_grid) +
  geom_text(data = grid_centroids, aes(x = X, y = Y, label = id)) +
  theme_void()

## End(Not run)

Nowosad/rgeopat2 documentation built on Sept. 19, 2023, 12:30 a.m.