st_joins | R Documentation |
Both st_left_join()
and st_inner_join()
are wrappers around sf::st_join()
with
appropriate argument handling for left
.
Both st_anti_join()
and st_semi_join()
are wrappers around sfx::st_any()
used within
dplyr::filter()
(plus the application of
logical !
where appropriate).
st_left_join(x, y, ...)
st_inner_join(x, y, ...)
st_right_join(x, y, ...)
st_semi_join(x, y, join = sf::st_intersects, ...)
st_anti_join(x, y, join = sf::st_intersects, ...)
x |
object of class |
y |
object of class |
... |
arguments passed on to the |
join |
geometry predicate function with the same profile as st_intersects; see details |
suppressPackageStartupMessages(library(sf))
suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(dplyr))
data(states_map)
data(ngp)
show_map <- function (x) {
ggplot(x) +
geom_sf(data = tx) +
geom_sf(color = "red") +
theme_void()
}
# MUTLIPOLYGON of the US state of Texas
tx <- states_map %>%
filter(region == "texas")
# [Semi-join] Intersects (Default)
ngp %>%
st_semi_join(tx) %>%
show_map()
# [Semi-join] Coveredy by
ngp %>%
st_semi_join(tx, sf::st_covered_by) %>%
show_map()
# [Anti-join] Intersects (Default)
ngp %>%
st_anti_join(tx) %>%
show_map()
# [Inner-join] Intersects (Default)
ngp %>%
st_inner_join(tx)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.