Ok.
The point now is that I have the sources (in Fortran) of the program that produces the graph with the map. And have to attach the information about the xrange and yrange to this graph in order for them to be read from R. Id est, I have to write: first longitude, first latitude, last longitude, last latitude, and also, the "figure" coordinates of the bounding box of the map in the figure. If I produce the map in eps, I can open it as a text file from the same fortran rogram, and modify the contents of the eps file in order to put the coordinates information into it. Then, once the fortran program has ended, I convert the eps to png using ImageMagic, because the EBImage library doesn't read eps, but png. In order for the png to contain the same properties as the eps, these have to be correctly defined in the eps. So, the question now is: how can I properly define properties in a eps, so that these are preserved in the convertion to png?. Perhaps this is not for this forum, but I haven't found information about it in the internet. Antonio Serrano aasde...@aim.com ن -----Original Message----- From: Jim Lemon <drjimle...@gmail.com> To: Antonio Serrano <aasde...@aim.com> Sent: Sun, Apr 26, 2015 1:03 am Subject: Re: [R] Interactive maps Hi Antonio, If you mean the normalized figure coordinates (i.e. from 0 to 1) then you want something like this: loc_convert<-function(n=1,xrange=c(0,1),yrange=c(0,1)) { plot_loc<-locator(n=n) plot_loc$x<-plot_loc$x/diff(xrange)+xrange[1] plot_loc$y<-plot_loc$y/diff(yrange)+yrange[1] return(plot$loc) } where xrange and yrange are the longitudes and latitudes respectively. Jim On Sun, Apr 26, 2015 at 1:09 AM, Antonio Serrano <aasde...@aim.com> wrote: > Thank you, Jim: > > I have tried your suggestion and I get the following error: > > Error en rasterImage(image = "map.eps", : > invalid color name 'map.eps' > > I have tried with three formats of the same image: svg, gif and eps, with > the same result. > > But I have found a possible better way to accomplish this objective in the > following thread: > http://r.789695.n4.nabble.com/Loading-an-image-picture-png-jpeg-to-screen-td2244923.html > > In short: > > library(gridExtra) > library(EBImage) > library(RGraphics) > x <- readImage("http://www.google.com/logos/teachersday09.gif") > g1 <- ebimageGrob(x) > dev.new(width=g1$width/72, height=g1$height/72) > plot.new() > grid.draw(g1) > c=locator(n=1, type="n") > > Then, when I click on the map, I get the "figure" coordinates where I > clicked, and still have to translate these to longitude-latitude. > > And here comes another question: How can I attach the first longitude, last > longitude, fisrt latitude, last latitude, to a JPEG, PNG or TIFF graphic?. > These are the formats supported by the EBImage package. > > > > Antonio Serrano > aasde...@aim.com > ن > > > -----Original Message----- > From: Jim Lemon <drjimle...@gmail.com> > To: Antonio Serrano <aasde...@aim.com> > Sent: Sat, Apr 25, 2015 8:36 am > Subject: Re: [R] Interactive maps > > Hi Antonio, > Try the rasterImage function. > > Jim > > > On Sat, Apr 25, 2015 at > 4:19 PM, Antonio Serrano <aasde...@aim.com> wrote: >> Thank you, Jim. >> >> I > didn't know the existence of the locator() function. But I can see now >> that I > don't know how to read a graphic image into R to work with it. >> How can I read > a pre-exisiting image into R?. >> >> Thanks again >> >> >> Antonio Serrano >> > aasde...@aim.com >> ن >> >> >> -----Original Message----- >> From: Jim Lemon > <drjimle...@gmail.com> >> To: Antonio Serrano <aasde...@aim.com> >> Cc: r-help > mailing list <r-help@r-project.org> >> Sent: Sat, Apr 25, 2015 5:47 am >> > Subject: Re: [R] Interactive maps >> >> Hi Antonio, >> If you do create the map > in R, you can use >> locator(). >> >> Jim >> >> >> On Sat, Apr 25, 2015 at 8:37 > AM, Antonio Serrano via >> R-help >> <r-help@r-project.org> wrote: >>> >>> > Hello, all: >>> >>> I am new here, >> and have a challenge to present some > graphical data to the user in a >> convenient >> way. >>> >>> The challenge > is to present a map to the user which is coloured >> with the value of a > variable. Say for example, temperature. This is a >> preexisting graph that I > can generate in any format, including svg. I don't >> have >> to produce it > using R. >>> >>> When the user clicks anywhere in the map, the >> coordinates > (longitude and latitude) have to be passed to R so that this, R, >> can >> look > for the values of other variables in that location and make another >> graph >> > with them. >>> >>> Does anyubody know how could I accomplish > this?. >>> >>> >> Thanks in advance. >>> >>> >>> >>> Antonio Serrano >>> > aasde...@aim.com >>> ن >>> >>> >>> >> [[alternative HTML version > deleted]] >>> >>> >> ______________________________________________ >>> > R-help@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. [[alternative HTML version deleted]] ______________________________________________ R-help@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.