Stuck in ggmap: Error in readPNG(destfile, native = native) : file is not in PNG format

1,442 views
Skip to first unread message

Sam Albers

unread,
Mar 16, 2012, 2:55:14 PM3/16/12
to ggplot2
Hello all,

I am having some trouble with ggmap. I apologize if this isn't the
right place to ask this question but after David Kahle's post this
week I was interested in trying ggmap out. However, when I try to
create a ggmap object I keep getting the same error. The corresponding
plot is created in the working directory as "ggmapTemp.jpg" but an
object isn't create and so I am not able to really take advantage of
all the great stuff of ggmap. Any thoughts?

> WashingtonMap_df <- ggmap(location = 'washington', verbose = TRUE)
grabbing map... Error in readPNG(destfile, native = native) : file is
not in PNG format
>
> lonR <- c(-97.12008, -97.11836)
> latR <- c(31.54765, 31.54911)
> osm <- ggmap(latR = latR, lonR = lonR, source = 'osm', scale = 1000)
Error in readPNG(destfile, native = native) : file is not in PNG format
>
> baylor <- ggmap('baylor university', zoom = 16,
+ maptype = 'satellite', regularize = FALSE, verbose = TRUE)
grabbing map... Error in readPNG(destfile, native = native) : file is
not in PNG format

> sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
[5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8 LC_PAPER=C
LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] grid stats graphics grDevices utils datasets
methods base

other attached packages:
[1] ggmap_1.3 rjson_0.2.7 proto_0.3-9.2
reshape2_1.2.1 plyr_1.7.1 scales_0.2.0
[7] ggplot2_0.9.0 ReadImages_0.1.3.1 RgoogleMaps_1.2.0 png_0.1-4

loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2
MASS_7.3-17 memoise_0.1 munsell_0.3
[7] RColorBrewer_1.0-5 stringr_0.6 tools_2.14.2


Thanks in advance!

Sam

Tony McDonald

unread,
Mar 19, 2012, 5:52:20 PM3/19/12
to ggplot2
I am having the same problem, using 32-bit Windows.

I've tried using the GetMap.bbox() function in RGoogleMaps and that
seems to work fine for ".png" files. However the GetMaps.OSM (which
ggmap wraps around) does not work and throws the same error. It seems
to me that the error lies somewhere in that function.


My session info is:


R version 2.14.2 (2012-02-29)
Platform: i386-pc-mingw32/i386 (32-bit)



attached base packages:
[1] splines grid tcltk tools stats graphics
grDevices
[8] utils datasets methods base

other attached packages:
[1] lmSupport_1.05 gvlma_1.0.0.1 ggmap_1.3
rjson_0.2.7
[5] proto_0.3-9.2 pROC_1.4.4 caret_5.01-001
foreach_1.3.2
[9] codetools_0.2-8 iterators_1.0.3 reshape_0.8.3
ez_3.0-1
[13] stringr_0.6 scales_0.2.0 reshape2_1.2.1
RCurl_1.91-1.1
[17] plyr_1.7.1 memoise_0.1 mgcv_1.7-13
lme4_0.999375-42
[21] Matrix_1.0-4 ggplot2_0.9.0 RGraphics_1.0-9
pixmap_0.4-11
[25] ReadImages_0.1.3.1 RgoogleMaps_1.2.0 png_0.1-3
randomForest_4.6-2
[29] ada_2.0-2 rpart_3.1-48 gbm_1.6-3.1
survival_2.36-12
[33] ROCR_1.0-4 e1071_1.6 class_7.3-3
lattice_0.20-0
[37] kernlab_0.9-13 gplots_2.8.0 caTools_1.12
bitops_1.0-4.1
[41] gdata_2.8.1 gtools_2.6.2 psych_1.0-94
corrgram_1.1
[45] seriation_1.0-6 colorspace_1.0-1 gclus_1.3
TSP_1.0-6
[49] cluster_1.14.2 car_2.0-12 nnet_7.3-1
SciViews_0.9-2
[53] ellipse_0.3-5 MASS_7.3-17 svGUI_0.9-50
svMisc_0.9-60

loaded via a namespace (and not attached):
[1] dichromat_1.2-4 digest_0.4.2 munsell_0.3
nlme_3.1-103
[5] RColorBrewer_1.0-2 stats4_2.14.2

Tony McDonald

unread,
Mar 19, 2012, 6:11:28 PM3/19/12
to ggplot2
I have traced the error from:

ggmap -> RgoogleMaps::GetMap.OSM -> RgoogleMaps::ReadMapTile ->
png::readPNG (line 5 of ReadMapTile)

removing and reinstalling the "png" library had no effect, and it
seems like the default destfile argument for ggmap ends in ".png"

I must say I am thoroughly confused.

Felipe Carrillo

unread,
Mar 19, 2012, 11:52:47 PM3/19/12
to ggplot2
I don't get any error message when running the code below, what
version of ggmap are you using?

WashingtonMap_df <- ggmap(location = 'washington', verbose = TRUE)
str(WashingtonMap_df)
ggmapplot(WashingtonMap_df)

It nicely prints a map of Washington

Tony McDonald

unread,
Mar 20, 2012, 4:53:19 PM3/20/12
to ggplot2
I am using version 1.3

Sam Albers

unread,
Mar 20, 2012, 5:03:36 PM3/20/12
to Tony McDonald, ggplot2
I also only get the error message on a Ubuntu machine (11.10). On
windows 7, ggmap runs smoothly.

I am also running ggmap 1.3 and ggplot 0.9

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Tony McDonald

unread,
Mar 20, 2012, 5:10:38 PM3/20/12
to ggplot2
I should have specified, I am using Windows 7 (32-bit) and getting the
error. I have not tried other OS.

Tony McDonald

unread,
Mar 20, 2012, 5:11:46 PM3/20/12
to ggplot2
Can you please print out your session info so that I can compare it to
mine? I'm wondering if I've overwritten a function or if I'm behind in
some of my upgrades.

On Mar 19, 10:52 pm, Felipe Carrillo <mazatlanmex...@yahoo.com> wrote:

Felipe Carrillo

unread,
Mar 20, 2012, 5:18:32 PM3/20/12
to Tony McDonald, ggplot2
Sure, I am also attaching the graphic:
 
> WashingtonMap_df <- ggmap(location = 'washington', verbose = TRUE)
grabbing map... done.
>  str(WashingtonMap_df)
 chr [1:640, 1:640] "#E8F3E5" "#D3DECE" "#DAE5D4" "#D0DCC8" "#ACB8A0" "#B7C4A8" "#D2E1C2" "#C5D4B3" "#C7D7B3" "#C2D3AF" ...
 - attr(*, "class")= chr [1:2] "ggmap" "raster"
 - attr(*, "bb")='data.frame':  1 obs. of  4 variables:
  ..$ ll.lat: num 38.6
  ..$ ll.lon: num -77.5
  ..$ ur.lat: num 39.2
  ..$ ur.lon: num -76.6
>  ggmapplot(WashingtonMap_df)
 
> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252   
attached base packages:
 [1] grid      grDevices datasets  splines   graphics  stats     tcltk     utils     methods   base    
other attached packages:
 [1] mapproj_1.1-8.3      maps_2.2-3           ggmap_1.3            rjson_0.2.6          proto_0.3-9.2        reshape2_1.2.1       plyr_1.7.1         
 [8] scales_0.2.0         ggplot2_0.9.0        ReadImages_0.1.3.1   RgoogleMaps_1.1.9.15 png_0.1-4            svSocket_0.9-51      TinnR_1.0.3        
[15] R2HTML_2.2           Hmisc_3.9-0          survival_2.36-10     rcom_2.2-3.1         rscproxy_1.3-1     
loaded via a namespace (and not attached):
 [1] cluster_1.14.1     colorspace_1.1-0   dichromat_1.2-4    digest_0.5.1       lattice_0.20-0     MASS_7.3-16        memoise_0.1      
 [8] munsell_0.3        RColorBrewer_1.0-5 stringr_0.6        svMisc_0.9-63      tools_2.14.1  
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsub...@googlegroups.com
More options: http://groups.google.com/group/ggplot2


DC.jpeg

David Kahle

unread,
Mar 20, 2012, 5:35:02 PM3/20/12
to Felipe Carrillo, Tony McDonald, ggplot2
Hi Tony, Felipe -

Sam and I traced the problem to where you did, Tony, but I haven't had a good chance to look at why it's happening yet.  My feeling at the time was that it was just a linux problem, but as you indicate it seems like it may be something stranger than that.

I have not encountered the problem on any Mac/PC machine I've used; and I don't have a linux box so it's more difficult for me to test it there.  In a few days I should have some time to take a more detailed look at it.  ATM I'm a bit bogged down with a few other things. 

Cheers
david.

PS - Felipe's graphic is the right one.

<DC.jpeg>

Tony McDonald

unread,
Mar 20, 2012, 6:34:15 PM3/20/12
to ggplot2
David Thanks in advance for looking into things.

The only thing I have noticed between Sam and my code verses Felipe's
is that he is using R 2.14.1 and Sam and I are on version 2.14.2. I
am not too familiar with the changes between the two versions, but
that may be the place to start looking.

best,
-Tony

JOHN ANDERSON

unread,
Mar 22, 2012, 4:51:46 PM3/22/12
to ggp...@googlegroups.com
I am experiencing the same error on Windows 7 with 64-bit R 2.14.2. I am able
to call RgoogleMaps::GetMap directly with no errors.

R version 2.14.2 (2012-02-29)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
character(0)

other attached packages:
[1] ggmap_1.3

loaded via a namespace (and not attached):
[1] base_2.14.2 colorspace_1.1-1 datasets_2.14.2
[4] dichromat_1.2-4 digest_0.5.2 ggplot2_0.9.0
[7] graphics_2.14.2 grDevices_2.14.2 grid_2.14.2
[10] MASS_7.3-17 memoise_0.1 methods_2.14.2
[13] munsell_0.3 plyr_1.7.1 png_0.1-4
[16] proto_0.3-9.2 RColorBrewer_1.0-5 ReadImages_0.1.3.1
[19] reshape2_1.2.1 RgoogleMaps_1.2.0 rjson_0.2.8
[22] scales_0.2.0 stats_2.14.2 stringr_0.6
[25] tools_2.14.2 utils_2.14.2


Reply all
Reply to author
Forward
0 new messages