Re: [R] How to plot a image with restrictions?

From: Roger Bivand <Roger.Bivand_at_nhh.no>
Date: Thu 22 Jun 2006 - 17:56:28 EST


On Wed, 21 Jun 2006, Cleber N.Borges wrote:

>
>
> Hello All!
>
>
> How to plot a image ( image function )
> with restrictions, like a polygon??

The suggestions given in:

http://finzi.psych.upenn.edu/R/Rhelp02a.new/archive/15030.html

by Denis White let you overplot the image with a masking polygon - that may be the most suitable for you. Alternatively, you can set the image values to be omitted to NA, but how you would do this depends rather on whether the polygon is irregular or not. If the polygon is regular, unrolling the image into a vector and setting conditions on expand.grid() of the row and column coordinates will work with is.na(). If irregular, you'll need to do point-in-polygon checking of the image grid coordinates. If your data are geographical (not assumed here), you may like to follow this up on the R-sig-geo list.

Roger

>
> Thanks in advance!
>
> Cleber N. Borges
>
>
> ##### problem example
>
> x <- y <- seq(-4*pi, 4*pi, len=27)
> r <- sqrt(outer(x^2, y^2, "+"))
> image( z )
> contour(z, add = TRUE, drawlabels = FALSE)
>
> m=scan()
> 0.2 0.2
> 0.8 0.2
> 0.5 0.8
>
> m = matrix(m,nr=3,byrow=T)
> polygon( m, lwd=5 )
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand@nhh.no

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Jun 22 17:59:33 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 22 Jun 2006 - 20:11:44 EST.

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