[R-sig-Geo] reading tiff with jump?

Ashton Shortridge ashton at msu.edu
Tue Aug 5 15:52:21 CEST 2008


On Tuesday 05 August 2008, Roger Bivand wrote:
> On Tue, 5 Aug 2008, Agustin Lobo wrote:
> > Hi!
> >
> > is it possible to read a tiff file with readGDAL but just keeping
> > one pixel every p columns and q lines? That is,
> > a systematic sampling at reading. This is good to save memory
> > and still be able of displaying and performing
> > statistics. As images are large,
> > reading in the entire image and then sampling is not
> > an alternative.
> > If this is not contemplated in the readGDAL function,
> > is there any way to just read in one line, perform
> > the sampling and then go on with the next line?
> >
> > I think I did this with binary images few years
> > ago, but using tiff would be much better for
> > practical reasons.
>
> Look at the offset=, band= and region.dim= arguments to readGDAL() - you
> could capture the GDALinfo() output to set the frame if need be. It may be
> more efficient to use GDAL.open()/GDAL.close() and getRasterData() at a
> lower level if you are taking many samples - loop over different values of
> offset= with region.dim=c(1,1). Note that offset= may be from the NW
> corner, not the SW corner, and that the arguments are (often) ordered
> (y, x).
>
> Roger

I'll just add to that: opening raster files is fairly expensive, so if you are 
sampling many locations over many tiffs you will see great speed improvements 
if you order your sampling by tiff to minimize the opens.

Yours,

Ashton

-- 
Ashton Shortridge
Associate Professor			ashton at msu.edu
Dept of Geography			http://www.msu.edu/~ashton
235 Geography Building		ph (517) 432-3561
Michigan State University		fx (517) 432-1671




More information about the R-sig-Geo mailing list