2

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

geo
  • 65
  • 4
  • png is not a georeferenced format. What exactly are you trying to acheive? It may be possible to add spatial metadata to a png file (see here https://stackoverflow.com/questions/9542359/does-png-contain-exif-data-like-jpg), but I'm not sure that's what you want – dww May 29 '18 at 03:27
  • Thanks, to clarify, I need it to keep the lat/long data so that I can send to other libraries to add supplementary lat/long data – geo May 29 '18 at 03:43
  • Is "georeferenced png" a standard format? Can you provide a link to that format if so? – Marius May 29 '18 at 03:44
  • Marius thanks - eg: library(orloca), data(andalusia), 'andalusian_provinces.png' – geo May 29 '18 at 03:51

0 Answers0