Hello R Help, I am fairly new to R and have been scouring the internet trying to find useful tips, tricks and advice with how to solve my problems with R. I finally was able to find you guys, and am now asking for your help. I have a number of different questions regarding R. My most pressing question is, how does one get a map of a very specific area into R? I've been following a tutorial that one of my teachers sent me and been following his code. However, every time I input this code I get a warning message: My teacher's code:> plot(map, col="dimgray", border=F, add=T)The Error code I get every time I input the above code:> Error in plot.window(...) : need finite 'ylim' valuesIn addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf 4: In plot.window(...) : "border" is not a graphical parameter 5: In plot.window(...) : "add" is not a graphical parameter So, what I think I figured out was that I didn't possess the "map" that my teacher had in his R program. So I went to try and figure out how to get my own map into my R session. I found this line of code to try and input a good Google Earth map I found that I need for my study. But, alas, this code didn't work either and I got more Error codes. The code I used:> img <-readPNG(system.file("img", "Seal_Island_Map.png", package="png"))The Error code I get every time I input the above code:> Error in readPNG(system.file("img", "Seal_Island_Map.png",package="png")) : unable to open For the life of me, I have not been able to find anything anywhere that can help me solve these problems. What am I doing wrong? Can you all help? Thank you and I hope to talk to you all soon. Sincerely, Jackson [[alternative HTML version deleted]]
If you haven't already done so, I strongly recommend that you stop doing what you're doing until you first spend some time with an R tutorial or two. You can find some good suggestions here: https://www.rstudio.com/online-learning/#R rseek.org is also a good resource for R queries; "plot maps" brought up lots of relevant hits. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Nov 19, 2016 at 10:32 AM, Jackson Hooten <jlhooten at eckerd.edu> wrote:> Hello R Help, > > I am fairly new to R and have been scouring the internet trying to find > useful tips, tricks and advice with how to solve my problems with R. I > finally was able to find you guys, and am now asking for your help. I have > a number of different questions regarding R. My most pressing question is, > how does one get a map of a very specific area into R? I've been following > a tutorial that one of my teachers sent me and been following his code. > However, every time I input this code I get a warning message: > > My teacher's code: >> plot(map, col="dimgray", border=F, add=T) > > The Error code I get every time I input the above code: >> Error in plot.window(...) : need finite 'ylim' values > In addition: Warning messages: > 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion > 2: In min(x) : no non-missing arguments to min; returning Inf > 3: In max(x) : no non-missing arguments to max; returning -Inf > 4: In plot.window(...) : "border" is not a graphical parameter > 5: In plot.window(...) : "add" is not a graphical parameter > > So, what I think I figured out was that I didn't possess the "map" that my > teacher had in his R program. So I went to try and figure out how to get my > own map into my R session. I found this line of code to try and input a > good Google Earth map I found that I need for my study. But, alas, this > code didn't work either and I got more Error codes. > > The code I used: >> img <-readPNG(system.file("img", "Seal_Island_Map.png", package="png")) > > The Error code I get every time I input the above code: >> Error in readPNG(system.file("img", "Seal_Island_Map.png", > package="png")) : unable to open > > > For the life of me, I have not been able to find anything anywhere that can > help me solve these problems. What am I doing wrong? Can you all help? > Thank you and I hope to talk to you all soon. > > Sincerely, > Jackson > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
This question is a bit too vague for the R mailing lists. For general advice on using this list, read the Posting Guide linked in the footer of this and every post on this list. One key recommendation made there is to send plain text emails because html frequently corrupts your example code so we cannot run it. For suggestions about making clear examples... read [1] and/or [2]. This is critical. For starting points on analyzing spatial data, look at [3]. Keep in mind that for many types of spatial analysis a bitmap image won't be enough, so you need to find vector representations of maps. Also note that there is a dedicated mailing list called R-sig-geo for discussing this kind of analysis. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example [2] http://adv-r.had.co.nz/Reproducibility.html [3] https://cran.r-project.org/web/views/Spatial.html -- Sent from my phone. Please excuse my brevity. On November 19, 2016 10:32:46 AM PST, Jackson Hooten <jlhooten at eckerd.edu> wrote:>Hello R Help, > >I am fairly new to R and have been scouring the internet trying to find >useful tips, tricks and advice with how to solve my problems with R. I >finally was able to find you guys, and am now asking for your help. I >have >a number of different questions regarding R. My most pressing question >is, >how does one get a map of a very specific area into R? I've been >following >a tutorial that one of my teachers sent me and been following his code. >However, every time I input this code I get a warning message: > >My teacher's code: >> plot(map, col="dimgray", border=F, add=T) > >The Error code I get every time I input the above code: >> Error in plot.window(...) : need finite 'ylim' values >In addition: Warning messages: >1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion >2: In min(x) : no non-missing arguments to min; returning Inf >3: In max(x) : no non-missing arguments to max; returning -Inf >4: In plot.window(...) : "border" is not a graphical parameter >5: In plot.window(...) : "add" is not a graphical parameter > >So, what I think I figured out was that I didn't possess the "map" that >my >teacher had in his R program. So I went to try and figure out how to >get my >own map into my R session. I found this line of code to try and input a >good Google Earth map I found that I need for my study. But, alas, this >code didn't work either and I got more Error codes. > >The code I used: >> img <-readPNG(system.file("img", "Seal_Island_Map.png", >package="png")) > >The Error code I get every time I input the above code: >> Error in readPNG(system.file("img", "Seal_Island_Map.png", >package="png")) : unable to open > > >For the life of me, I have not been able to find anything anywhere that >can >help me solve these problems. What am I doing wrong? Can you all help? >Thank you and I hope to talk to you all soon. > >Sincerely, >Jackson > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
On 19/11/2016 1:32 PM, Jackson Hooten wrote:> Hello R Help, > > I am fairly new to R and have been scouring the internet trying to find > useful tips, tricks and advice with how to solve my problems with R. I > finally was able to find you guys, and am now asking for your help.You can find a fairly recently edited discussion of how to get help at https://www.r-project.org/help.html I have> a number of different questions regarding R. My most pressing question is, > how does one get a map of a very specific area into R? I've been following > a tutorial that one of my teachers sent me and been following his code. > However, every time I input this code I get a warning message: > > My teacher's code: >> plot(map, col="dimgray", border=F, add=T) > > The Error code I get every time I input the above code: >> Error in plot.window(...) : need finite 'ylim' values > In addition: Warning messages: > 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion > 2: In min(x) : no non-missing arguments to min; returning Inf > 3: In max(x) : no non-missing arguments to max; returning -Inf > 4: In plot.window(...) : "border" is not a graphical parameter > 5: In plot.window(...) : "add" is not a graphical parameter > > So, what I think I figured out was that I didn't possess the "map" that my > teacher had in his R program. So I went to try and figure out how to get my > own map into my R session. I found this line of code to try and input a > good Google Earth map I found that I need for my study. But, alas, this > code didn't work either and I got more Error codes. > > The code I used: >> img <-readPNG(system.file("img", "Seal_Island_Map.png", package="png")) > > The Error code I get every time I input the above code: >> Error in readPNG(system.file("img", "Seal_Island_Map.png", > package="png")) : unable to open > > > For the life of me, I have not been able to find anything anywhere that can > help me solve these problems. What am I doing wrong? Can you all help? > Thank you and I hope to talk to you all soon.You need to tell R where the "Seal_Island_Map.png" file is sitting. The "system.file(...)" call you used says it's a file in the "png" package, but it's not. The easiest way to find a file is to use the file.choose() function to open a file selection dialog, e.g. filename <- file.choose() readPNG(filename) Duncan Murdoch
Hello, First of all, there's a no homework policy in R-Help, but since it's the first time you post I'll try to give some help. Now, you are trying to call two functions in one statement, system.file and readPNG. If you separate the calls, you will see that the call to system.file is returning an empty string: system.file("img", "Seal_Island_Map.png", package="png") [1] "" You should then read the help page for function system.file. You do this by typing at an R prompt ?system.file system.file is looking in directory 'img' for a file named Seal_Island_Map.png but in that directory of package png there's just one file, RLogo.png. So you have to ask your teacher where to find that file, and what function does he use to display it [tip: it's not function plot()]. Hope this helps, Rui Barradas Em 19-11-2016 18:32, Jackson Hooten escreveu:> Hello R Help, > > I am fairly new to R and have been scouring the internet trying to find > useful tips, tricks and advice with how to solve my problems with R. I > finally was able to find you guys, and am now asking for your help. I have > a number of different questions regarding R. My most pressing question is, > how does one get a map of a very specific area into R? I've been following > a tutorial that one of my teachers sent me and been following his code. > However, every time I input this code I get a warning message: > > My teacher's code: >> plot(map, col="dimgray", border=F, add=T) > > The Error code I get every time I input the above code: >> Error in plot.window(...) : need finite 'ylim' values > In addition: Warning messages: > 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion > 2: In min(x) : no non-missing arguments to min; returning Inf > 3: In max(x) : no non-missing arguments to max; returning -Inf > 4: In plot.window(...) : "border" is not a graphical parameter > 5: In plot.window(...) : "add" is not a graphical parameter > > So, what I think I figured out was that I didn't possess the "map" that my > teacher had in his R program. So I went to try and figure out how to get my > own map into my R session. I found this line of code to try and input a > good Google Earth map I found that I need for my study. But, alas, this > code didn't work either and I got more Error codes. > > The code I used: >> img <-readPNG(system.file("img", "Seal_Island_Map.png", package="png")) > > The Error code I get every time I input the above code: >> Error in readPNG(system.file("img", "Seal_Island_Map.png", > package="png")) : unable to open > > > For the life of me, I have not been able to find anything anywhere that can > help me solve these problems. What am I doing wrong? Can you all help? > Thank you and I hope to talk to you all soon. > > Sincerely, > Jackson > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Rui Barradas, Thank you very much for your help! This isn't an actual homework assignment, it's an independent project that I'm conducting that my teacher was just giving me a tutorial to help me. Thank you again! Sincerely, Jackson Sent from my iPhone> On Nov 19, 2016, at 3:33 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote: > > Hello, > > First of all, there's a no homework policy in R-Help, but since it's the first time you post I'll try to give some help. > > Now, you are trying to call two functions in one statement, system.file and readPNG. If you separate the calls, you will see that the call to system.file is returning an empty string: > > system.file("img", "Seal_Island_Map.png", package="png") > [1] "" > > You should then read the help page for function system.file. You do this by typing at an R prompt > > ?system.file > > system.file is looking in directory 'img' for a file named Seal_Island_Map.png but in that directory of package png there's just one file, RLogo.png. So you have to ask your teacher where to find that file, and what function does he use to display it [tip: it's not function plot()]. > > Hope this helps, > > Rui Barradas > > Em 19-11-2016 18:32, Jackson Hooten escreveu: >> Hello R Help, >> >> I am fairly new to R and have been scouring the internet trying to find >> useful tips, tricks and advice with how to solve my problems with R. I >> finally was able to find you guys, and am now asking for your help. I have >> a number of different questions regarding R. My most pressing question is, >> how does one get a map of a very specific area into R? I've been following >> a tutorial that one of my teachers sent me and been following his code. >> However, every time I input this code I get a warning message: >> >> My teacher's code: >>> plot(map, col="dimgray", border=F, add=T) >> >> The Error code I get every time I input the above code: >>> Error in plot.window(...) : need finite 'ylim' values >> In addition: Warning messages: >> 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion >> 2: In min(x) : no non-missing arguments to min; returning Inf >> 3: In max(x) : no non-missing arguments to max; returning -Inf >> 4: In plot.window(...) : "border" is not a graphical parameter >> 5: In plot.window(...) : "add" is not a graphical parameter >> >> So, what I think I figured out was that I didn't possess the "map" that my >> teacher had in his R program. So I went to try and figure out how to get my >> own map into my R session. I found this line of code to try and input a >> good Google Earth map I found that I need for my study. But, alas, this >> code didn't work either and I got more Error codes. >> >> The code I used: >>> img <-readPNG(system.file("img", "Seal_Island_Map.png", package="png")) >> >> The Error code I get every time I input the above code: >>> Error in readPNG(system.file("img", "Seal_Island_Map.png", >> package="png")) : unable to open >> >> >> For the life of me, I have not been able to find anything anywhere that can >> help me solve these problems. What am I doing wrong? Can you all help? >> Thank you and I hope to talk to you all soon. >> >> Sincerely, >> Jackson >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >>
To go further with your teacher's code, I would start by finding out what kind of object "map" is, in R terms. For example, can your teacher give you the output from the commands: class(map) str(map) ? Without that information, I don't think anyone here can give you effective help. Also, as one if the others mentioned, R-sig-geo would be a better place to ask, when you come back with that information. (And mention up front that this is not homework, to avoid getting that advice again. Folks will appreciate it.) As a general rule, loading images, such as a png file, may or may not result in an object with correct map coordinates; it depends on the incoming file. You could also go back to the CRAN webpage, click on "Task Views" on the left, then click on "Spatial". There is a LOT of material there. The first two packages to look at, from my perspective, would be sp and rgdal (especially if you're going to be doing a lot of serious spatial work in R) but there are plenty of others that could be relevant for your particular needs. See also the raster package if your starting point is really going to be an image such as a png file. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 11/19/16, 10:32 AM, "R-help on behalf of Jackson Hooten" <r-help-bounces at r-project.org on behalf of jlhooten at eckerd.edu> wrote:>Hello R Help, > >I am fairly new to R and have been scouring the internet trying to find >useful tips, tricks and advice with how to solve my problems with R. I >finally was able to find you guys, and am now asking for your help. I have >a number of different questions regarding R. My most pressing question is, >how does one get a map of a very specific area into R? I've been following >a tutorial that one of my teachers sent me and been following his code. >However, every time I input this code I get a warning message: > >My teacher's code: >> plot(map, col="dimgray", border=F, add=T) > >The Error code I get every time I input the above code: >> Error in plot.window(...) : need finite 'ylim' values >In addition: Warning messages: >1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion >2: In min(x) : no non-missing arguments to min; returning Inf >3: In max(x) : no non-missing arguments to max; returning -Inf >4: In plot.window(...) : "border" is not a graphical parameter >5: In plot.window(...) : "add" is not a graphical parameter > >So, what I think I figured out was that I didn't possess the "map" that my >teacher had in his R program. So I went to try and figure out how to get >my >own map into my R session. I found this line of code to try and input a >good Google Earth map I found that I need for my study. But, alas, this >code didn't work either and I got more Error codes. > >The code I used: >> img <-readPNG(system.file("img", "Seal_Island_Map.png", package="png")) > >The Error code I get every time I input the above code: >> Error in readPNG(system.file("img", "Seal_Island_Map.png", >package="png")) : unable to open > > >For the life of me, I have not been able to find anything anywhere that >can >help me solve these problems. What am I doing wrong? Can you all help? >Thank you and I hope to talk to you all soon. > >Sincerely, >Jackson > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.