You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I'm plotting global raster data with geom_spatraster using the Equal Earth or Kavrayskiy V projections, the data is duplicated outside the 180° line. With other equal area projections such as the Eckert IV, plotting works like charm.
Behaviour is as expected with the vector data (country and land borders).
Code excerpt:
library(terra)
library(tidyterra)
coordRefSys <- "+proj=eqearth"
countrPoly <- vect(file.path(dirPoly, "countries.shp"))
countrPoly <- crop(countrPoly, ext(-179.99, 179.99, ymin(countrPoly), ymax(countrPoly )))
landPoly <- aggregate(countrPoly, dissolve = TRUE)
rusleRast <- rast(file.path(dirRast, "RUSLE_Baseline_2020_30s.tif"))
# Here I tried clipping data along 180°, but to no avail
# rusleRast <- crop(rusleRast, ext(-179,179,ymin(rusleRast), ymax(rusleRast)))
rusle <- ggplot() +
geom_spatvector(
data = landPoly, fill = "grey90", colour = NA
) +
geom_spatraster(data = rusleRast, maxcell = 1e+6) +
scale_fill_gradientn(
colours = c("darkgreen", "yellow", "tomato3"),
values = rescale(c(0, 1, 3, 5, 10, 20, 50)),
limits = c(0, 50),
breaks = c(0, 1, 3, 5, 10, 20, 50),
na.value = NA,
labels = c("0 - 1", "1 - 3", "3 - 5", "5 - 10", "10 - 20", "20 - 50", ">50"),
name = expression(atop("Soil loss by water erosion [Mg ha"^-1 * " year"^-1 * "]"))
) +
geom_spatvector(
data = countrPoly, fill = NA, colour = "black", linewidth = 0.25
) +
coord_sf(crs = coordRefSys, clip = "on")
The text was updated successfully, but these errors were encountered:
When I'm plotting global raster data with
geom_spatraster
using the Equal Earth or Kavrayskiy V projections, the data is duplicated outside the 180° line. With other equal area projections such as the Eckert IV, plotting works like charm.Behaviour is as expected with the vector data (country and land borders).
Code excerpt:
The text was updated successfully, but these errors were encountered: