library(png) gmap <- readPNG("staticmap.png") library(raster) Lon <- -4.02 Lat <- 40.78 Test <-raster("test.tif") library(grid) green <- "#007020" rgb <- col2rgb(green) lch <- as(sRGB(t(rgb/255)), "polarLUV") bg <- hcl(lch@coords[,3], 10, 90) svg("rasterplot.svg") # plot.new() # grid.roundrect(gp=gpar(col=NA, fill=bg), r=unit(.05, "snpc")) # par(new=TRUE) plot(Test, maxpixels=(640*640), col=c("transparent", adjustcolor(colorRampPalette(c("white", "red"))(10)))) dev.off() svg("map.svg") grid.raster(gmap) dev.off() svg("mapoverlay.svg") # Set up the coordinate system plot(Test, maxpixels=(640*640), col="transparent") # Draw the google map in the plot region rasterImage(gmap, -4.68841552734375, 40.27533480732468, -3.3563232421875, 41.28399850538595) # Redo original plot, WITH semitransparent colours par(new=TRUE) plot(Test, maxpixels=(640*640), col=c("transparent", adjustcolor(colorRampPalette(c("white", "red"))(10), alpha.f=.3))) contour(Test, add=TRUE) dev.off()