% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bbox-to-poly.R
\encoding{UTF-8}
\name{bbox_to_poly}
\alias{bbox_to_poly}
\title{Convert a bounding box to an \code{\link[sf:st_sfc]{sfc}} \code{POLYGON} object}
\usage{
bbox_to_poly(bbox = NA, xmin = NA, ymin = NA, xmax = NA, ymax = NA, crs = 4326)
}
\arguments{
\item{bbox}{A numeric vector of four bounding box coordinates in the form
\code{c(xmin, ymin, xmax, ymax)}.}

\item{xmin, ymin, xmax, ymax}{A numeric value specifying an individual bounding
box coordinate. Use these arguments as an alternative to \code{bbox}.}

\item{crs}{coordinate reference system, something suitable as input to \link[sf]{st_crs}}
}
\value{
An \code{\link[sf:st_sfc]{sfc}} object with \code{POLYGON} geometry and the coordinate
reference system specified by \code{crs}.
}
\description{
Converts bounding box coordinates to an \code{\link[sf:st_sfc]{sfc}} object with
\code{POLYGON} geometry.
}
\details{
Bounding boxes can be located using online tools such as
\url{https://boundingbox.klokantech.com/}.
}
\examples{
\dontshow{if (nominatim_check_access() && requireNamespace("ggplot2")) withAutoprint(\{ # examplesIf}
# Convert the bounding box for Germany.
bbox_GER <- c(5.86631529, 47.27011137, 15.04193189, 55.09916098)

bbox_GER_sf <- bbox_to_poly(bbox_GER)

library(ggplot2)

ggplot(bbox_GER_sf) +
  geom_sf()
\donttest{
# Extract the bounding box of an `sf` object.
sfobj <- geo_lite_sf("seychelles", points_only = FALSE)

sfobj

# Require at least one non-empty object.
if (!all(sf::st_is_empty(sfobj))) {
  bbox <- sf::st_bbox(sfobj)

  bbox

  bbox_sfobj <- bbox_to_poly(bbox)

  ggplot(bbox_sfobj) +
    geom_sf(fill = "lightblue", alpha = 0.5) +
    geom_sf(data = sfobj, fill = "wheat")
}
}
\dontshow{\}) # examplesIf}
}
\seealso{
\code{\link[sf:st_as_sfc]{sf::st_as_sfc()}} and \code{\link[sf:st_sfc]{sf::st_sfc()}}.

Spatial helper and output functions:
\code{\link[=geo_address_lookup_sf]{geo_address_lookup_sf()}},
\code{\link[=geo_amenity_sf]{geo_amenity_sf()}},
\code{\link[=geo_lite_sf]{geo_lite_sf()}},
\code{\link[=geo_lite_struct_sf]{geo_lite_struct_sf()}},
\code{\link[=reverse_geo_lite_sf]{reverse_geo_lite_sf()}}
}
\concept{spatial}
