Re: [R] how to plot image() without painting a map (the background)

From: Rob Robinson <rob.robinson_at_bto.org>
Date: Tue, 19 Feb 2008 17:44:21 +0000


I've used a similar three-stage approach. Depending on the format of your map (mine came from an ArcView shape file) you may be able to specify col="transparent" for the foreground (ie land) in plot as I did (tip, use border= to get colours for the country borders). This works where alpha channels don't, such as png.
Not sure what image you have, but there may be alternatives, for example, I found .Internal(filledcontour()) extremely useful because then I could explicitly set some of the image to "transparent"... Hth
rob

Dr Rob Robinson, Senior Population Biologist British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU

Ph: +44 (0)1842 750050         E: rob.robinson_at_bto.org
Fx: +44 (0)1842 750030         W: http://www.bto.org

> -----Original Message-----
> From: r-help-bounces_at_r-project.org
> [mailto:r-help-bounces_at_r-project.org] On Behalf Of Greg Snow
> Sent: 19 February 2008 17:20
> To: Ptit_Bleu; r-help_at_r-project.org
> Subject: Re: [R] how to plot image() without painting a map
> (the background)
>
> The approach that I usually use for things like this is:
>
> Plot the map to get the aspect ratio and limits correct.
> Add the image (obscuring the original map).
> Add the map again on top of the image using a light grey color.
>
> This seems to work fine for me. Another aproach that you may
> try (untested) is to use colors with an alpha channel
> (transparency) in the call to image, then the background map
> may show through. Not all graphics devices support alpha
> channels, so test on one that does.
>
> Hope this helps,
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.snow_at_imail.org
> (801) 408-8111
>
>
>
> > -----Original Message-----
> > From: r-help-bounces_at_r-project.org
> > [mailto:r-help-bounces_at_r-project.org] On Behalf Of Ptit_Bleu
> > Sent: Monday, February 18, 2008 8:59 AM
> > To: r-help_at_r-project.org
> > Subject: [R] how to plot image() without painting a map (the
> > background)
> >
> >
> > Hello,
> >
> > I'm trying to plot dayly evolution of the temperature over
> France from
> > Global Forecast System files ("I'm trying" is the right
> > expression...).
> >
> > akilonlat03 is the temperature for different latitudes and
> longitudes
> > 3 o'clock.
> > akilonlat06 is the temperature for different latitudes and
> longitudes
> > 6 o'clock.
> >
> > I would like to plot akilonlat03 and then akilonlat06 and
> keep the map
> > of France in background.
> > My script (see below) doesn't work as image "paints" the
> background as
> > I read somewhere in this forum.
> >
> > So would have someone a solution to correct my script ?
> > Thanks in advance,
> > Ptit Bleu.
> >
> > ----------------------------------------------------
> >
> >
> > akilonlat03<-interp(lonlat03$Longitude, lonlat03$Latitude,
> > (5/9)*(lonlat03$TMP_200802150300-32))
> > akilonlat06<-interp(lonlat06$Longitude, lonlat06$Latitude,
> > (5/9)*(lonlat06$TMP_200802150600-32))
> >
> > map('france')
> >
> > image(akilonlat03, col=cm.colors(100), axes=FALSE, add=TRUE)
> > #contour(akilonlat03, col="blue", add=TRUE) image(akilonlat06,
> > col=cm.colors(100), axes=FALSE, add=TRUE) #contour(akilonlat06,
> > col="blue", add=TRUE)
> >
> > --
> > View this message in context:
> > http://www.nabble.com/how-to-plot-image%28%29-without-painting
> > -a-map-%28the-background%29-tp15546906p15546906.html
> > Sent from the R help mailing list archive at Nabble.com.
> >
> > ______________________________________________
> > R-help_at_r-project.org mailing list
> > 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.
> >
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> 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.
>



R-help_at_r-project.org mailing list
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. Received on Tue 19 Feb 2008 - 17:59:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Feb 2008 - 09:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive