3

I keep getting this error Error in readPNG(destfile) : libpng error: PLTE: CRC error with the following code:

map <- get_map(location='Auckland', source="stamen", maptype="toner", zoom=11)
ggmap(map)

This does works however:

map <- get_map(location='Auckland', source="stamen", maptype="toner", zoom=13)
ggmap(map)

Any ideas? I get the feeling that this may be an issue with Stamen maps rather than ggmap. If so, I will take it to them.

Sandy Muspratt
  • 31,719
  • 12
  • 116
  • 122
Phil Donovan
  • 1,075
  • 1
  • 9
  • 18

1 Answers1

1

I can get the two maps, but not consistently. If I get an error, I run the code a second or a third time to get the maps drawn. I don't think it's got anything to do with zoom levels. Nothing systematic, but I get the same error message with other zoom levels; even the same zoom level in the two maps.

The error message I get is:

  Error in download.file(urls[[k]], destfile = destfile, quiet = !messaging,  : 
     cannot open destfile 'ggmapTemp.png', reason 'Permission denied'

The file, ggmapTemp.png, is generated by ggmap in the working directory, but I don't know how it is involved.

I ran the following code to draw the two maps:

library(ggmap)
map <- get_map(location='Auckland', source="stamen", maptype="toner", zoom=11)
ggmap(map)
windows()
map <- get_map(location='Auckland', source="stamen", maptype="toner", zoom=13)
ggmap(map)

I'm using R version 2.15.0, ggplot2 version 0.9.1, and ggmap version 2.1

enter image description here enter image description here

Sandy Muspratt
  • 31,719
  • 12
  • 116
  • 122
  • Thanks for this Sandy. I could not reproduce your exact error but it after three consecutive attempts at it, the problem seems to have sorted itself out. I think it is probably an issue at the Stamen end; possibly the server. – Phil Donovan Jul 02 '12 at 10:39