This requires the rgdal and sp packages to be installed, and assumes a
3-bandfile called image.tif

## (untested)
library(rgdal)
x <- readGDAL("image.tif")

## first band
red <- as.image.SpatialGridDataFrame(x[1])$z
## second
green <- as.image.SpatialGridDataFrame(x[2])$z
## third
 blue <- as.image.SpatialGridDataFrame(x[3])$z

The 1,2,3 indexing is syntax for "this SpatialGridDataFrame with just these
bands", so that sp:::image.SpatialGridDataFrame can convert simply to the
list x/y/z format for image().

HTH



On Tue, Oct 19, 2010 at 10:59 PM, Roger Gill <roger.gill1...@yahoo.co.uk>wrote:

> Dear listers,
>
> I have a collection of tif images that I would like to convert, in R, to a
> matrix containing the values of the 8bit colour. Ideally, I would like a
> matrix
> for each of the colour channels (red, blue and green). I have 'googled' and
> searched the help list but have yet to find a solution and hope that
> someone can
> point me in the right direction.
>
> I currently use subscription software (Igor) for the conversion and would
> prefer
> to use R.
>
> Best wishes,
>
> Roger
>
>
>
>
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@gmail.com

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to