Skip to content

Commit

Permalink
add missing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
h-a-graham committed Oct 11, 2024
1 parent 6aa8afa commit e1c7b91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
13 changes: 4 additions & 9 deletions R/rstac_bbox.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
#'
#' @return A numeric of length 4 defining the xmin, ymin, xmax ymax coordinates
#' of the search extent in WGS84 (EPSG:4326).
#' @rdname rstac_bbox
#' @export
#'
#' @examples
#'
#' rstac_bbox(c(-121.772, 45.321, -121.611, 45.419))
#'
#'
#' #' if (requireNamespace("sf", quietly = TRUE)) {
#' nc_sf <- system.file("gpkg", "nc.gpkg", package = "sf") |>
#' sf::read_sf()
Expand All @@ -23,43 +22,37 @@ rstac_bbox <- function(x) {
}

#' @rdname rstac_bbox
#'
#' @export
rstac_bbox.sf <- function(x) {
sf_method(x)
}

#' @rdname rstac_bbox
#'
#' @export
rstac_bbox.sfc <- function(x) {
sf_method(x)
}

#' @rdname rstac_bbox
#'
#' @export
rstac_bbox.stars <- function(x) {
sf_method(x)
}


#' @rdname rstac_bbox
#'
#' @export
rstac_bbox.SpatRaster <- function(x) {
terra_method(x)
}

#' @rdname rstac_bbox
#'
#' @export
rstac_bbox.SpatVector <- function(x) {
terra_method(x)
}

#' @rdname rstac_bbox
#'
#' @export
rstac_bbox.numeric <- function(x) {
checkmate::assert_numeric(x, lower = -180, upper = 180, len = 4)
Expand All @@ -71,13 +64,15 @@ rstac_bbox.numeric <- function(x) {


#' @noRd
#' @keywords internal
sf_method <- function(x) {
x <- sf::st_transform(x, "EPSG:4326") |>
sf::st_bbox()
x[c(1:4)]
}

#' @noRd
#' @keywords internal
terra_method <- function(x) {
x <- terra::project(x, "EPSG:4326") |>
terra::ext()
Expand Down
7 changes: 6 additions & 1 deletion man/rstac_bbox.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e1c7b91

Please sign in to comment.