. Advertisement .
. Advertisement .
In the process of completing my work, I encountered the following problem:
> source('mow.R')  "Note that when center and zoom are not specified, no meta information on the map tile can be stored. This basically means that R cannot compute proper coordinates. You can still download the map tile and view it in R but overlays are not possible. Do you want to proceed ? (y/n)" y  "&40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc"  "http://maps.google.com/maps/api/staticmap?size=640x640&maptype=terrain&format=png32&sensor=true&40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc" Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection In addition: Warning message: In readChar(con, 5L, useBytes = TRUE) : cannot open compressed file 'MyTile1.png.rda', probable reason 'No such file or directory' >
Below is the code I ran:
library(RgoogleMaps); png(filename="RgoogleMaps-package_%03d_med.png", width=480, height=480); MyMap <- GetMap(markers='&40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc', destfile="MyTile1.png");
> sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-unknown-linux-gnu (64-bit) locale:  LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C  LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8  LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8  LC_PAPER=C LC_NAME=C  LC_ADDRESS=C LC_TELEPHONE=C  LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages:  stats graphics grDevices utils datasets methods base other attached packages:  RgoogleMaps_1.2.0 png_0.1-4 >
What’s causing it, and how can it be resolved in the “error in readchar(con, 5l, usebytes = true) : cannot open the connection“ in the programs?
You received the error ”cannot open the connection problem” perhaps due to there is no such file or directory like that.
Below is the working code:
It leads to the following result: