I'm trying to generate a set of sample points within a set of islands. I generate the coastline data as follows:
library(osmdata)
bb <- getbb(place_name= "Shetland")
osm_box <- opq(bbox = bb) %>%
add_osm_feature(key = "natural", value = "coastline") %>%
osmdata_sf()
And then I create an sf
feature of MULTIPOLYGON:
library(sf)
coast <- osm_box$osm_lines %>%
st_union() %>%
st_line_merge() %>%
st_cast("MULTIPOLYGON") %>%
st_transform(27700)
This seems to be ok. Now when I try to generate my sample points:
coast %>% st_sample(1000, type= "hexagonal")
I get one features of geometry type POINT instead of what I expect, 1000 features of POINT all located within the MULTIPOLYGON.
Geometry set for 1 feature
geometry type: POINT
dimension: XY
bbox: xmin: 396882.7 ymin: 1138217 xmax: 396882.7 ymax: 1138217
epsg (SRID): 27700
proj4string: +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs
POINT (396882.7 1138217)
Any ideas?!