Skip to content

Instantly share code, notes, and snippets.

@ryanscharf
Created May 13, 2021 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanscharf/ea6e69a1548de2f33c72c3ce543aeea0 to your computer and use it in GitHub Desktop.
Save ryanscharf/ea6e69a1548de2f33c72c3ce543aeea0 to your computer and use it in GitHub Desktop.
## @y dataframe of coordinates
## @x vector of buffer sizes for cone diameters
coneify <- function(y, x, ref){
points <- y %>% st_as_sf(coords = c('lng', 'lat'), crs = ref)
buffs <- st_buffer(points, points$x)
cone <- st_sf(st_sfc())
for (i in 2:nrow(buffs)) {
tmp <- buffs[(i - 1):i,]
cone[i,] <- st_convex_hull(st_union(tmp))
}
cone_u <- st_union(cone)
return(cone_u)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment