flip_y_spatraster | R Documentation |
These internal functions flip the y-coordinates of SpatRaster
and SpatVector
objects from the terra
package.
For rasters, the function vertically flips the raster and adjusts its extent accordingly.
For vectors, the function negates the y-coordinates of all geometries, supporting both point and polygon/line types.
flip_y_spatraster(data)
flip_y_spatvector(data)
data |
A |
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, a lot of elements have to be visualized with ggplot2::geom_sf()
, which won't work with
ggplot2::scale_y_reverse()
. See also this GitHub issue comment.
So we need these functions to flip the values along the y-axis and negate the y-coordinates.
This way, we can remove the negative sign from the y-axis labels to mimick the behavior of scale_y_reverse()
.#'
For flip_y_spatraster
, a SpatRaster
object with flipped y-coordinates and adjusted extent.
For flip_y_spatvector
, a SpatVector
object with y-coordinates negated.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.