allocate | R Documentation |
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 )
centroids |
a data frame with centroids of non empty polygons |
hex_grid |
a data frame containing all possible hexagon points |
sf_id |
a string to indicate the column to identify individual polygons |
hex_size |
a float value in degrees for the diameter of the hexagons |
hex_filter |
amount of hexagons around centroid to consider |
focal_points |
a data frame of reference locations when allocating hexagons, capital cities of Australia are used in the example |
order_sf_id |
a string to indicate the column used to order polygons |
width |
a numeric indicating the angle used to filter the hexagon grid |
verbose |
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 ) # NEXT: # create a set of hexagon points for plotting # using fortify_hexagon, and # plot the hexagons with geom_polygon, see vignette
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.