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

Jan.Verbesselt at csiro.au Jan.Verbesselt at csiro.au
Fri Jun 1 10:02:34 CEST 2007


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.

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()




More information about the R-sig-Geo mailing list