Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R ggmap (qmap) error for map type = 'watercolor'

Tags:

r

ggplot2

ggmap

I was trying to use the ggmap qmap function (http://www.inside-r.org/packages/cran/ggmap/docs/qmap)

qmap(location = 'baylor university', zoom = 14, maptype = 'watercolor', source = 'stamen')

And got the following error:

qmap(location = 'baylor university', zoom = 14, maptype = 'watercolor', source = 'stamen') Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=baylor+university&zoom=14&size=%20640x640&maptype=terrain&sensor=false Google Maps API Terms of Service : http://developers.google.com/maps/terms Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=baylor+university&sensor=false Google Maps API Terms of Service : http://developers.google.com/maps/terms Error in readPNG(destfile) : file is not in PNG format

like image 430
Concept Delta Avatar asked Nov 10 '22 09:11

Concept Delta


1 Answers

qmap tries to read the files as .pngs, but stamen sends .jpg format files, which the internal function in qmap is not equipped to handle. Hopefully a new version will be out soon.

Until then, there is a manual workaround, detailed at the link below, where you essentially create your own version of the R source files used by qmap, replacing png with jpg in the code. It worked for me:

https://stackoverflow.com/a/24301510/3652621

like image 51
Serban Tanasa Avatar answered Nov 15 '22 06:11

Serban Tanasa