Created
May 30, 2020 20:16
-
-
Save mhweber/b3d44434daae64a520932b4181279ebc to your computer and use it in GitHub Desktop.
Derive endpoints for spatial lines in sf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Create linestring | |
line <- st_as_sfc(c("LINESTRING(0 0 , 0.5 1 , 1 1 , 1 0.3)")) %>% | |
st_sf(ID = "poly1") | |
#Convert each vertex to point | |
pt <- st_cast(line, "POINT") | |
# Grab start or end point: | |
start <- pt[1,] | |
end <- pt[nrow(pt),] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment