Skip to content

Instantly share code, notes, and snippets.

@tim-salabim
Last active October 17, 2017 21:21
Show Gist options
  • Save tim-salabim/506ba39e635d91572a46958b3fcebd14 to your computer and use it in GitHub Desktop.
Save tim-salabim/506ba39e635d91572a46958b3fcebd14 to your computer and use it in GitHub Desktop.
sf with sf list column
library(mapview)
library(sf)
## create polygon index column
franconia$index = sprintf("%02.f", 1:nrow(franconia))
## join polygons to points
brew_franc = st_join(breweries, franconia[, c("index", "geometry")])
## split on polygon entity
brew_list = split(brew_franc, brew_franc$index)
## include list in polygon data as list column
franc = franconia[franconia$index %in% names(brew_list), ]
franc$breweries = I(brew_list)
## view selected feature
mapview(franc[4, ]) + mapview(franc[4, ]$breweries[[1]])
@tim-salabim
Copy link
Author

screenshot at 2017-10-17 23 21 07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment