0

I want to make a plot from raster data using levelplot. How to add a header which contains logo.png and title, like showed on this picture?

Here is my data: SST

Here is my basic code to produce this map:

r<-crop(raster(flname, varname="sst"), extent(90, 144, -20, 25))

png('SST.png', height = 2000, width = 2500, res = 300)
print(levelplot(r, col.regions = sst, at=seq(20, 34, 0.1),
              yscale.components=yscale.raster.subticks,
              xscale.components=xscale.raster.subticks,
              margin=FALSE, ylab='Latitude', xlab='Longitude', 
              main=paste0(flname,' (deg-C)')))
dev.off()

enter image description here

Emma
  • 27,428
  • 11
  • 44
  • 69
Eko Susilo
  • 250
  • 2
  • 15

1 Answers1

0

You can use package magick to compose images:

library(rasterVis)
library(magick)
header <- image_read("~/Desktop/headerWithLogo.png")
fig <- image_graph(width = 600, height = 600, res=96)
f <- system.file("external/test.grd", package="raster")
r <- raster(f)
levelplot(r, margin=F, main ="Test \n")
dev.off()
out <- image_composite(fig, header, offset = "+50-5")
print(out)

enter image description here

Christopher Stephan
  • 1,081
  • 16
  • 33