gistlib
# Create a dataset with 2 sets of coordinates data <- data.frame( x = c(1, 2, 3), y = c(4, 5, 6), x2 = c(7, 8, 9), y2 = c(10, 11, 12) ) # Convert to sf object with 2 geometry columns library(sf) coordinates <- st_as_sf(data, coords = c("x", "y"), coords2 = c("x2", "y2"), crs = st_crs("+proj=longlat +datum=WGS84")) print(coordinates) 398 chars17 lines
# Create a dataset with 2 sets of coordinates data <- data.frame( x = c(1, 2, 3), y = c(4, 5, 6), x2 = c(7, 8, 9), y2 = c(10, 11, 12) ) # Convert to sf object with 2 geometry columns library(sf) coordinates <- st_as_sf(data, coords = c("x", "y"), coords2 = c("x2", "y2"), crs = st_crs("+proj=longlat +datum=WGS84")) print(coordinates)
gistlibby LogSnag