These internal S3 methods flip the y-coordinates of SpatRaster,
SpatVector, and 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.
Usage
.flip_y(data, ...)
# S3 method for class 'SpatRaster'
.flip_y(data, ...)
# S3 method for class 'SpatVector'
.flip_y(data, ...)
# S3 method for class 'data.frame'
.flip_y(data, y = "y", ...)Value
For SpatRaster input, a SpatRaster flipped vertically with
negated y-extent. For SpatVector input, a SpatVector with
negated y-coordinates. For data.frame input, a data frame with the
specified y column 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,
geom_sf() does not work with
scale_y_reverse(). See
this
GitHub comment for details. These functions negate the y-coordinates so
that the axis labels can be displayed with reversed sign, mimicking
scale_y_reverse().
