For the sake of consistency of a presentation, I was wanting to create a georeferenced .png image from the output of either leaflet (ideally) or else ggmap.
****Updating to clarify my question****
My goal is to use the orloca package to work on a georeferenced .png file.
I now know I should be using the PNG package to write my .png file through the writePNG() function and append metadata.
My question remains:
1) Whether I can append metadata from leaflet or ggmap (ie a streetmap style view) to my .png file via the metadata argument of writePNG(). If so, then how?
2) If not then what type of map am I able to use to append the metadata to and how? (eg ggplot2?)
For an example of what I am trying to do please see : library(orloca) data(andalusia) 'andalusian_provinces.png'
*****Old question less clear*******
The closest I have come to this is trying to write a .tif file from the raster package:
library(raster)
writeRaster(nameofmapinleaflet, filename='myfilename.tif')
However, this gives the error:
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘writeRaster’ for signature ‘"leaflet", "character"’
for both leaflet and ggmap.
Similarly with rgdal:
writeGDAL(map, 'test.png')
I get the error:
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘gridded’ for signature ‘"ggmap"’
Is it in fact possible to create a georeferenced .png from these functions?
Many thanks