Im trying to use the sf package in R to see if sf object is within another sf object with the st_within
function. My issue is with the output of this function w
Here is how you can get a logical vector from sparse geometry binary predicate:
df$indicator <- st_within(df, box) %>% lengths > 0
or to subset without creating a new variable:
df <- df[st_within(df, box) %>% lengths > 0,]
I cannot test on your large dataset unfortunately but please let me know if it is faster than matrix approach.