[R] Edges and Rasters

Sarah Goslee sarah.goslee at gmail.com
Wed Jun 20 17:41:03 CEST 2012


Here's one way to do it, preserving your original approach as much as
possible. (Note: I'm not sure how well "transparent" is supported on
other devices or OSs [I'm using Cairo on Linux], but since you don't
say what you're using it's impossible to provide a definite solution.)

plot(r,col=terrain.colors(100))
plot(edge(r, type="outer"), col=c("transparent", "black"), add=TRUE,
legend=FALSE)

If this doesn't work for you because of problems with "transparent",
you can also change the 0 values in edge(r) to NA so they won't be
plotted.

Sarah

On Wed, Jun 20, 2012 at 9:19 AM, riodementa <jorge.nayamacias at gmail.com> wrote:
> Hi everyone!
>
> I would like to draw a line surrounding my raster, with i want it in black,
> and i don't know if its possible to change the colour.
>
> A simple example is:
>
> r <- raster(nrow=30, ncol=30, xmn=0)
> r[]<-NA
> r[393:409]<-99
> r[423:439]<-99
> r[453:455]<-99
> r[456:460]<-30
> r[461:469]<-99
> r[483:499]<-99
> r[513:529]<-99
> plot(r,col=terrain.colors(100))
> plot( edge(r, type='outer'))
>
> Could anyone help me??
> Thanks
>

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list