gpat_st_make_grid: Grid polygon creator (without a header)

Description Usage Arguments Value References Examples

View source: R/gpat_create_grid.R

Description

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

Usage

1
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

sfc_POLYGON

References

Based on the st_make_grid function from the sf package

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
library(sf)
nc = st_read(system.file("shape/nc.shp", package="sf"))

my_grid = gpat_st_make_grid(nc) %>%
  st_as_sf(data.frame(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)

rgeopat2 documentation built on May 2, 2019, 4:01 p.m.