I have a raster file(1440*720 rows) contains values of 1 ,2 , and 3. when I plot the file , I got a map of three colors but I do not know which is which. How can I put those colors as as I want : 1=red 2=blue 3=green code: pvm <- file("C:\\User_sm-das.bin","rb") cor1<- readBin(pvm, numeric(), size=4, n=1440*720, signed=TRUE) r <-raster(t(matrix((data=cor1), ncol=720, nrow=1440))) image(r) -- View this message in context: http://r.789695.n4.nabble.com/How-to-represent-certain-values-in-a-file-as-we-want-tp4662925.html Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2013-Mar-31 19:22 UTC
[R] How to represent certain values in a file as we want?
On Mar 31, 2013, at 6:15 AM, Jonsson wrote:> I have a raster file(1440*720 rows) contains values of 1 ,2 , and 3. when I > plot the file , I got a map of three colors but I do not know which is > which. How can I put those colors as as I want : > > 1=red > 2=blue > 3=green > code: > > pvm <- file("C:\\User_sm-das.bin","rb") > cor1<- readBin(pvm, numeric(), size=4, n=1440*720, signed=TRUE) > r <-raster(t(matrix((data=cor1), ncol=720, nrow=1440)))Wouldn't this just be: image(r, col=c("red", "blue", "green")[r])> image(r) >Nabble falsehoods deleted. -- David Winsemius Alameda, CA, USA