% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spatialplot.R
\name{.flip_y}
\alias{.flip_y}
\alias{.flip_y.SpatRaster}
\alias{.flip_y.SpatVector}
\alias{.flip_y.data.frame}
\title{Flip y-coordinates for spatial data objects}
\usage{
.flip_y(data, ...)

\method{.flip_y}{SpatRaster}(data, ...)

\method{.flip_y}{SpatVector}(data, ...)

\method{.flip_y}{data.frame}(data, y = "y", ...)
}
\arguments{
\item{data}{A \code{SpatRaster}, \code{SpatVector}, or \code{data.frame}.}

\item{...}{Additional arguments (not used).}

\item{y}{A character string specifying the y column name for \code{data.frame}
input. Ignored for \code{SpatRaster} and \code{SpatVector}. Default is \code{"y"}.}
}
\value{
For \code{SpatRaster} input, a \code{SpatRaster} flipped vertically with
negated y-extent. For \code{SpatVector} input, a \code{SpatVector} with
negated y-coordinates. For \code{data.frame} input, a data frame with the
specified \code{y} column negated.
}
\description{
These internal S3 methods flip the y-coordinates of \code{SpatRaster},
\code{SpatVector}, and \code{data.frame} objects.

For rasters, the raster is flipped vertically and its extent is negated.
For vectors, the y-coordinates of all geometries are negated.
For data frames, the specified y column is negated.
}
\details{
These functions are intended for internal use to facilitate coordinate
transformations. When visualizing spatial data, it is often necessary to
flip the y-axis to put the origin at the top-left corner. However,
\code{\link[ggplot2]{geom_sf}()} does not work with
\code{\link[ggplot2]{scale_y_reverse}()}. See
\href{https://github.com/tidyverse/ggplot2/issues/4021#issuecomment-650787582}{this
GitHub comment} for details. These functions negate the y-coordinates so
that the axis labels can be displayed with reversed sign, mimicking
\code{scale_y_reverse()}.
}
\keyword{internal}
