# \donttest{
# Get France boundary from built-in world map
france <- hexify_world[hexify_world$name == "France", ]
# Create grid clipped to France
grid <- hex_grid(area_km2 = 2000)
france_grid <- grid_clip(france, grid)
# Plot result
library(ggplot2)
ggplot() +
geom_sf(data = france, fill = "gray95") +
geom_sf(data = france_grid, fill = alpha("steelblue", 0.3),
color = "steelblue") +
theme_minimal()
# Keep only complete hexagons (no cropping)
france_grid_complete <- grid_clip(france, grid, crop = FALSE)
# }
Run the code above in your browser using DataLab