gistlib
# Creating a dataset with two sets of coordinates df <- data.frame( lon1 = c(10, 20), lat1 = c(50, 60), lon2 = c(30, 40), lat2 = c(70, 80) ) # Converting into spatial dataframe library(sf) coordinates <- c("lon1", "lat1") geometry1 <- st_as_sf(df, coords = coordinates, crs = 4326) coordinates <- c("lon2", "lat2") geometry2 <- st_as_sf(df, coords = coordinates, crs = 4326) # Display the spatial dataframes print(geometry1) print(geometry2) 453 chars20 lines
# Creating a dataset with two sets of coordinates df <- data.frame( lon1 = c(10, 20), lat1 = c(50, 60), lon2 = c(30, 40), lat2 = c(70, 80) ) # Converting into spatial dataframe library(sf) coordinates <- c("lon1", "lat1") geometry1 <- st_as_sf(df, coords = coordinates, crs = 4326) coordinates <- c("lon2", "lat2") geometry2 <- st_as_sf(df, coords = coordinates, crs = 4326) # Display the spatial dataframes print(geometry1) print(geometry2)
gistlibby LogSnag