[R-sig-Geo] writing tiff file by row {raster}

Alexander.Herr at csiro.au Alexander.Herr at csiro.au
Tue Dec 23 01:40:56 CET 2008


Hi List,

I can write out ascii grids by row (see below), but I can't figure out how to do this in say compressed geotiff or another compressed lossless format readable by ESRI.

require(rgdal)
require(raster)
# read and write row by row; write to ascii file
 rs <- raster.from.file(system.file("external/test.ag", package="sp"))
  #rs <- setNA(rs, operator ="<=", value=0)
 ascrow <- set.filename(rs, "ascrow.asc")
 for (r in 1:nrow(rs)) {
        rs <- readRow(rs, r)
          #rs <- setNA(rs, operator ="<", value=10)
         print(paste(nrow(rs)+1 - r, " rows to go"))
           vals<-values(rs)/4
           vals[values(rs)<=500]<-NA
          
        ascrow <- set.values.row(ascrow, vals, r)
        ascrow <- write.ascii(ascrow, overwrite=TRUE) 
 }

Any hints appreciated

Thanx
Herry



More information about the R-sig-Geo mailing list