Chooses a hexagon centroid for each polygon in the shape file, from a grid spanning the longitudes and latitudes in the expanded bounding box.
allocate(
centroids,
hex_grid,
sf_id = names(centroids)[1],
hex_size,
hex_filter,
focal_points = NULL,
order_sf_id = NULL,
width = 30,
verbose
)
a data frame with centroids of non empty polygons
a data frame containing all possible hexagon points
a string to indicate the column to identify individual polygons
a float value in degrees for the diameter of the hexagons
amount of hexagons around centroid to consider
a data frame of reference locations when allocating hexagons, capital cities of Australia are used in the example
a string to indicate the column used to order polygons
a numeric indicating the angle used to filter the hexagon grid
a boolean to indicate whether to show polygon id
a data frame of all allocated hexagon points
# Create centroids set
centroids <- create_centroids(tas_lga, sf_id = "lga_code_2016")
# Smaller set for faster example
centroids <- centroids[1:10,]
# Create hexagon location grid
data(capital_cities)
grid <- create_grid(centroids = centroids, hex_size = 0.2, buffer_dist = 1.2)
# Allocate polygon centroids to hexagon grid points
hex_allocated <- allocate(
centroids = centroids,
hex_grid = grid,
hex_size = 0.2, # same size used in create_grid
hex_filter = 3,
focal_points = capital_cities,
width = 30,
verbose = TRUE
)
#> Finding closest point in focal_points data set.
#> Allocating centroids, in order of distance to closest focal point.
# NEXT:
# create a set of hexagon points for plotting
# using fortify_hexagon, and
# plot the hexagons with geom_polygon, see vignette