# NOT RUN {
# Default S3 Method
# random geographic points within bbox(10, 12, 45, 47)
library("sf")
set.seed(123)
lonlat <- data.frame(lon = runif(2, 10, 12),
lat = runif(2, 45, 47))
gjson <- as.geojson(lonlat)
#################
# S3 Method for objects of class 'sf'
# random geographic points within bbox(10, 12, 45, 47)
library("sf")
set.seed(123)
lonlat <- data.frame(lon = runif(5, 10, 12),
lat = runif(5, 45, 47))
lonlat <- st_as_sf(lonlat, coords = c("lon","lat"))
gjson <- as.geojson(lonlat)
# }
Run the code above in your browser using DataLab