% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ddbs_coordinates.R
\name{ddbs_coord_bounds}
\alias{ddbs_coord_bounds}
\alias{ddbs_xmax}
\alias{ddbs_xmin}
\alias{ddbs_ymax}
\alias{ddbs_ymin}
\alias{ddbs_zmax}
\alias{ddbs_zmin}
\alias{ddbs_mmax}
\alias{ddbs_mmin}
\title{Coordinate bounds of geometries}
\usage{
ddbs_xmax(
  x,
  new_column = "xmax",
  by_feature = TRUE,
  conn = NULL,
  name = NULL,
  mode = NULL,
  overwrite = FALSE,
  quiet = FALSE
)

ddbs_xmin(
  x,
  new_column = "xmin",
  by_feature = TRUE,
  conn = NULL,
  name = NULL,
  mode = NULL,
  overwrite = FALSE,
  quiet = FALSE
)

ddbs_ymax(
  x,
  new_column = "ymax",
  by_feature = TRUE,
  conn = NULL,
  name = NULL,
  mode = NULL,
  overwrite = FALSE,
  quiet = FALSE
)

ddbs_ymin(
  x,
  new_column = "ymin",
  by_feature = TRUE,
  conn = NULL,
  name = NULL,
  mode = NULL,
  overwrite = FALSE,
  quiet = FALSE
)

ddbs_zmax(
  x,
  new_column = "zmax",
  by_feature = TRUE,
  conn = NULL,
  name = NULL,
  mode = NULL,
  overwrite = FALSE,
  quiet = FALSE
)

ddbs_zmin(
  x,
  new_column = "zmin",
  by_feature = TRUE,
  conn = NULL,
  name = NULL,
  mode = NULL,
  overwrite = FALSE,
  quiet = FALSE
)

ddbs_mmax(
  x,
  new_column = "mmax",
  by_feature = TRUE,
  conn = NULL,
  name = NULL,
  mode = NULL,
  overwrite = FALSE,
  quiet = FALSE
)

ddbs_mmin(
  x,
  new_column = "mmin",
  by_feature = TRUE,
  conn = NULL,
  name = NULL,
  mode = NULL,
  overwrite = FALSE,
  quiet = FALSE
)
}
\arguments{
\item{x}{Input spatial data. Can be:
\itemize{
\item A \code{duckspatial_df} object (lazy spatial data frame via dbplyr)
\item An \code{sf} object
\item A \code{tbl_lazy} from dbplyr
\item A character string naming a table/view in \code{conn}
}
Data is returned from this object.}

\item{new_column}{Name of the new column. Defaults to the lowercase function
name (e.g. \code{"xmax"}, \code{"xmin"}, \code{"ymax"}, \ldots).}

\item{by_feature}{Logical. If \code{TRUE}, the geometric operation is applied
separately to each geometry. If \code{FALSE}, the geometric
operation is applied to the data as a whole.}

\item{conn}{A connection object to a DuckDB database. If \code{NULL}, the function
runs on a temporary DuckDB database.}

\item{name}{A character string of length one specifying the name of the table,
or a character string of length two specifying the schema and table
names. If \code{NULL} (the default), the function returns the result as an
\code{sf} object}

\item{mode}{Character. Controls the return type. Options:
\itemize{
\item \code{"duckspatial"} (default): Lazy spatial data frame backed by dbplyr/DuckDB
\item \code{"sf"}: Eagerly collected sf object (uses memory)
}
Can be set globally via \code{\link{ddbs_options}(mode = "...")} or
per-function via this argument. Per-function overrides global setting.}

\item{overwrite}{Boolean. whether to overwrite the existing table if it exists. Defaults
to \code{FALSE}. This argument is ignored when \code{name} is \code{NULL}.}

\item{quiet}{A logical value. If \code{TRUE}, suppresses any informational messages.
Defaults to \code{FALSE}.}
}
\value{
\itemize{
\item \code{by_feature = TRUE} and \code{mode = "duckspatial"} (default):
A \code{duckspatial_df}.
\item \code{by_feature = TRUE} and \code{mode = "sf"}: A numeric vector.
\item \code{by_feature = FALSE}: A single \code{numeric} scalar.
\item When \code{name} is provided: writes the table in DuckDB and
returns \code{TRUE} (invisibly).
}
}
\description{
Returns the minimum or maximum value of a specific coordinate axis across
all points of a geometry. When \code{by_feature = TRUE} (default), a value
is computed per row. When \code{by_feature = FALSE}, a single global
value is returned for the entire dataset.
}
\details{
\itemize{
\item \code{ddbs_xmax()} / \code{ddbs_xmin()}: maximum / minimum X coordinate.
\item \code{ddbs_ymax()} / \code{ddbs_ymin()}: maximum / minimum Y coordinate.
\item \code{ddbs_zmax()} / \code{ddbs_zmin()}: maximum / minimum Z coordinate.
\item \code{ddbs_mmax()} / \code{ddbs_mmin()}: maximum / minimum M (measure) coordinate.
}

When \code{by_feature = FALSE}, the result is always a single \code{numeric}
scalar representing the global extreme across the entire dataset.
}
\examples{
\dontrun{
library(duckspatial)

argentina_ddbs <- ddbs_open_dataset(
  system.file("spatial/argentina.geojson", package = "duckspatial")
)

## per-feature X extent (default)
ddbs_xmax(argentina_ddbs)
ddbs_xmin(argentina_ddbs)

## global bounding values
ddbs_xmax(argentina_ddbs, by_feature = FALSE)
ddbs_ymin(argentina_ddbs, by_feature = FALSE)
}
}
