I want to make a global raster map in the rounded shape (hatano projection). I have raster from ERA5 data which is in GCS coordinate system.
I applied following code:
library(raster)
library(ggplot2)
library(viridis)
library(tidyterra)
library(terra)
setwd("C:/Users/usman/Desktop/a")
r= raster("SH.tif")
p = projectRaster(r, crs = "+proj=hatano",method = "bilinear")
g = graticule(60, 45, "+proj=hatano")
plot(g, background="azure", mar=c(.2,.2,.2,4), lab.cex=0.5, col="light gray")
myplot = plot(p, add=TRUE, axes=FALSE, plg=list(shrink=.8), col=viridis(25))
ggsave("tile_plot2.png", plot=myplot, height=4, width=6.5, dpi=150)`
And my output is
However, I want this
part of the code and the reference image is taken from the following thread R ggplot plotting map raster with rounded shape - How to remove data outside projected area?
Also, when I tried to save using a blank file is generated.