create_grid_from_poly: Create ISEA-3-HEXAGON_grid_from_polygon

Description Usage Arguments Value Examples

View source: R/create_grid_from_poly.R

Description

Create a hexagon grid covering the polygon object at given resolution. Set 'intersect_polygon' = T for a grid with only geometries that touch the polygon object, else a grid covering the bounding box of the object is returned.

Usage

1
2
create_grid_from_poly(polygon_object, grid_res, set_seed = F,
  intersect_polygon = T)

Arguments

polygon_object

A sf polygon object

grid_res

The desired grid resolution for the hex grid

set_seed

Give a string used to fix random seed for uuids

intersect_polygon

Boolean, intersect the grid with polygon object

Value

A sf::sf object where each feature is a hexagon with a unique uuid, area [m2], and perimeter [m].

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
bv <- create_biovar_stack(
region = 'biovar_Sweden',
biovar_list = c("biovar04", "biovar06", "biovar16"),
time_period = "biovar_historical",
path = "inst/ext_data/bioclimatic"
)
g <- create_grid_from_poly(bv$land_poly, grid_res=11, set_seed=999)
if(require(tmap)){
tmap_mode("view")
tm_shape(g)+ tm_fill("area_m2", palette = sf::sf.colors(3), alpha=0.7, colorNA=NULL,
legend.show = T)}else{plot(g)}

Vizzuality/vspt documentation built on Nov. 9, 2020, 10:38 p.m.