st_extent: Return the bounding box as 'sf' or 'sfc'

st_extentR Documentation

Return the bounding box as 'sf' or 'sfc'

Description

Return the bounding box as 'sf' or 'sfc'

Usage

st_extent(x, type = "sf")

Arguments

x

(sf/sfc) Spatial data

type

(character) Return type; either "sf" (Default) or "sfc"

Examples


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)


seasmith/sfx documentation built on April 1, 2024, 2:36 p.m.