Last chance! 50% off unlimited learning
Sale ends in
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
# NOT RUN {
# Create centroids set
centroids <- create_centroids(tas_lga, sf_id = "LGA_CODE16")
# 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 = 10,
focal_points = capital_cities,
width = 30, verbose = TRUE
)
# same column used in create_centroids
# create a set of hexagon points for plotting
fort_hex <- fortify_hexagon(data = hex_allocated, sf_id = "LGA_CODE16", hex_size = 0.2)
# plot the hexagons
# }
Run the code above in your browser using DataLab