Last active
January 27, 2017 11:47
-
-
Save obrl-soil/ee9904263b660bc2fb340264ca2da030 to your computer and use it in GitHub Desktop.
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
# subset out polygons from x that intersect polygons in y | |
# should work for other geom types too | |
get_intersecting <- function(x, y) { | |
df <- as.data.frame(st_intersects(x, y, sparse = FALSE)) | |
df$k <- apply(df, MARGIN = 1, FUN = function(x) ifelse(any(x) == TRUE, T, F)) | |
x$k <- df$k | |
xout <- filter(x, k == TRUE) | |
x$k <- NULL | |
xout$k <- NULL | |
return(xout) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment