Blue marble and Landsat in R 2.

I have just been asked if the images in the previous post could be produced simply in two dimensions so that points could be easily over plotted. The code to do this can be taken strait from the rimage package and very slightly adapted for a “SpatialGridDataFrame”. I haven’t worked out how it could be done using lattice.

spimage.doc
require(sp)
load(url(“https://duncanjg.files.wordpress.com/2008/03/bmmexicoapril.doc”))

sp.image.rgb<-function(d,red=1,green=3,blue=2,m=255){
colvec <- rgb(d[[red]],d[[green]],d[[blue]],m=255)
colors <- unique(colvec)
d[[“colmat”]] <- match(colvec, colors)
image(d,”colmat”,col=colors)
}

sp.image.rgb(d)

bm1.png


One thought on “Blue marble and Landsat in R 2.

  1. Roger Bivand has just sent me an alternative, rather more elegant way of achieving the result in this post. One of the great things about R is the constant discovery of features that you hadn’t used before and the generosity of those responsible for their development.

    library(rgdal)
    load(url(“https://duncanjg.files.wordpress.com/2008/03/bmmexicoapril.doc”))
    x <- d[c(1,3,2)]
    xc <- SGDF2PCT(x)
    x$idx <- xc$idx
    image(x, “idx”, col=xc$ct)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s