Last active
October 17, 2017 21:21
-
-
Save tim-salabim/506ba39e635d91572a46958b3fcebd14 to your computer and use it in GitHub Desktop.
sf with sf list column
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
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]]) |
Author
tim-salabim
commented
Oct 17, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment