[R] Interactive maps
Michael Sumner
mdsumner at gmail.com
Sun Apr 26 02:48:54 CEST 2015
On Sun, 26 Apr 2015 at 00:56 Antonio Serrano via R-help <
r-help at r-project.org> 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?.
>
> See the raster (and possibly rgdal - depending on your format/s) package
to read in images that are georeferenced. Depending on the provenance of
your files, it might be as simple as doing
library(raster)
r <- raster(filename)
plort(r)
xy <- locator(, type = "p") ## click on the map
If the values of these are not right you'll need further digging, and
perhaps if your image is not in longitude/latitude you'll need to transform
the locator points.
Also check out ?getGraphics event in grDevices, which can be used (with
care) to build quite complex interactive applications.
Another promising option is to use a Shiny application, where each plot
gives a simple way to get click events from the user - but then you really
are building an application out in the frontier edges of R land.
Cheers, Mike.
Thanks again
>
>
>
>
>
> Antonio Serrano
> aasdelat at aim.com
> ن
>
>
>
>
>
> -----Original Message-----
> From: Jim Lemon <drjimlemon at gmail.com>
> To: Antonio Serrano <aasdelat at aim.com>
> Cc: r-help mailing list <r-help at 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 at 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
> > aasdelat at aim.com
> > ن
> >
> >
> >
> [[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.
>
>
>
> [[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.
[[alternative HTML version deleted]]
More information about the R-help
mailing list