st_extent | R Documentation |
Return the bounding box as 'sf' or 'sfc'
st_extent(x, type = "sf")
x |
(sf/sfc) Spatial data |
type |
(character) Return type; either |
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(ggplot2))
data(states_map)
tx_extent <- states_map %>%
filter(region == "texas") %>%
st_extent()
class(tx_extent)
# Can use in joins
ngp %>%
st_anti_join(tx_extent) %>%
ggplot() +
geom_sf(data = states_map) +
geom_sf(data = tx_extent, fill = NA) +
geom_sf(color = "red")
states_map %>%
st_anti_join(tx_extent) %>%
ggplot() +
geom_sf() +
geom_sf(data = tx_extent, fill = NA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.