ggmap雄蕊水彩png错误 [英] ggmap stamen watercolor png error

查看:163
本文介绍了ggmap雄蕊水彩png错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很感谢有关ggmap和雄蕊水彩画的问题的帮助/想法.

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 create a stamen watercolor map:

"Error in readPNG(destfile) : file is not in PNG format"

以下是一些简单代码返回此错误的示例:

Here are some examples of simple code that is returning this error:

qmap("new-york", zoom=13, source="stamen", maptype="watercolor")

get_map(location='Auckland', source="stamen", maptype="watercolor", zoom=13)

我正在使用r版本:[默认] [64位] Windows 8下的C:\ Program Files \ R \ R-3.0.2

I am using r version: [Default] [64-bit] C:\Program Files\R\R-3.0.2 under windows 8

我知道有几个人发布了有关同一问题的信息-但只有少数人-我还没有看到任何解释/建议.我感到沮丧和沮丧,真的希望比我有更多经验的人遇到(并解决)了这个问题.在此先感谢您或您可以提供的任何帮助

I realize a few people have posted about this same problem - but only a few - and I haven't seen any explanations / suggestions. I'm stumped and frustrated and am really hoping someone with more experience than me has run into (and solved) this problem. Thanks in advance or any help you can provide

推荐答案

作为临时解决方案,您可以自己进行更改.键入

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

get_stamenmap 

在R终端上

.这将转储用于加载地图的代码.您将需要编辑此代码并替换名称空间中的函数.

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 = 

然后,您需要切换到加载jpeg.搜索png并将文本更改为jpg.我有两个实例,它们看起来像文件扩展名中所需的文本,对我来说它们分别位于第64行和第71行.

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 = ".")

第75行有readPNG函数,您需要将其更改为readJPEG.

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

tile <- readJPEG(destfile)

您还需要确保加载jpeg软件包,即library(jpeg),因为ggmap否则不会意识到现在需要这样做.我还需要library(plyr),但我不知道为什么-之所以这样做是因为我后来在该软件包中找到了有关ldply()的错误消息.

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")

现在您应该可以再次使用qmap了.此程序对我有用,比重新编译具有相同更改的程序包或下载具有这些修复程序和编译功能的最新源代码更简单.

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.

这篇关于ggmap雄蕊水彩png错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆