[R-sig-Geo] Optimize image plot of a grid with legend - colors - and extras ?

Roger Bivand Roger.Bivand at nhh.no
Fri Jun 1 11:00:58 CEST 2007


On Fri, 1 Jun 2007 Jan.Verbesselt at csiro.au wrote:

> Thanks Roger,
> 
> It's all working now ; I plotted a shape file on top of a spatial grid
> image via the following script. Only, when you change the colors of the
> image() the axis colors also change. I couldn't solve this and tried
> several options (par, axis(), etc), but nothing worked.

In order to find this out, please provide an example with the meuse.grid 
dataset shipped with sp, and for the shape, the meuse.riv river contour. 
It may be that the col= argument is being passed through by accident to 
plot.Spatial(), but without a reproducible example, it is difficult to 
say.

Roger

> 
> I also used image.plot() of the fields library to add a legend to the
> image.
> 
> Does somebody has some advise how to optimize these type of spatial
> image -grid plots with a legend, colors, and other extra's? 
> 
> All examples are welcome,
> Cheers and thanks,
> Jan
> 
> 
> # combining the  usual image function and adding a legend
> # first change margin for some more room
> nr <- 100
> ramp <- colorRamp(c("blue", "green"))
> kleur <- rgb( ramp(seq(0, 1, length = nr)), max = 255)
> par( mar=c(5,5,5,8), col.axis =1)
> image(GRID, col=kleur, axes=T)
> plot(shape,add =TRUE , border = "red", axes=F, las=1)
> image.plot( zlim=c(min(data["ndvi"]),max(data["ndvi"])),
> nlevel=nr,legend.only=TRUE, horizontal=F, col=kleur)
> box()
> 
> 
> 

-- 
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 at nhh.no




More information about the R-sig-Geo mailing list