Draws points uniformly over the area of each cell on the sphere, as
DGGRID's randpts output does. Each point is assigned back to its
cell by lonlat_to_cell, so the points of a cell are exactly
the points the grid places in it. Use set.seed() for a reproducible
draw.
Value
A data frame with columns cell_id, lon and
lat, the points of each cell together in the order of
cell_id.
Details
Points are drawn uniformly in a spherical cap around the cell centre that holds the whole cell, and those outside the cell are drawn again.
See also
cell_to_lonlat for cell centres
Examples
grid <- hex_grid(resolution = 3, aperture = 3)
cell <- lonlat_to_cell(10, 50, grid)
set.seed(1)
pts <- hex_sample(cell, grid, n = 200)
plot(sf::st_geometry(cell_to_sf(cell, grid)))
points(pts$lon, pts$lat, pch = 20, cex = 0.5)