ggmap stamen watercolor png error

前端 未结 3 1573
花落未央
花落未央 2021-02-09 00:21

I would really appreciate some help / ideas about a problem I am having with ggmap and stamen watercolor.

I keep getting the same error message every time I try to cre

3条回答
  •  离开以前
    2021-02-09 01:08

    As a temporary fix you can do the change yourself. Type

    get_stamenmap 
    

    at the R terminal. This will dump out the code for loading the maps. You will need to edit this code and replace the function in the namespace.

    Copy the code to a text editor and make if a function again by changing the first line:

    get_stamenmap <- function (bbox = 
    

    Then you need to switch over to loading jpegs. Search on png and change the text to jpg. I had two instances which looked like the text you need in the file extension, they were on line 64 and 71 for me.

    64: urls <- paste(urls, ".jpg", sep = "")
    71: destfile <- paste(filename, "jpg", sep = ".")
    

    On line 75 there is the function readPNG, which you need to change to readJPEG.

    tile <- readJPEG(destfile)
    

    You will also need to ensure to load the jpeg package, i.e. library(jpeg) since ggmap does not otherwise realise this is now needed. I also needed library(plyr) but I did not figure out why - I did this because I got a later error message about ldply() which I found in that package.

    Now paste this "all new" function back into the terminal. Afterwards, you need to overwrite the function embedded in the package, which is different from the local copy you just pasted into the terminal, so you need to type this:

    assignInNamespace("get_stamenmap",get_stamenmap,ns="ggmap")
    

    Now you should be ready to use qmap again. This procedure worked for me and was simpler than recompiling the package with the same changes or downloading the latest source which has these fixes and compiling.

提交回复
热议问题