rs <- raster(system.file("external/test.grd", package="raster"))
# read a row
firstrow <- readRow(rs, 1)
lastrow <- readRow(rs, rs@nrows)
# read a number of rows
fiverows <- readRows(rs, startrow=50, nrows=5)
# read a block
block <- readBlock(rs, startrow=50, nrows=5, startcol=30, ncolumns=10)
# read a row from a stack
st <- stack(rs, rs, rs)
st <- readRow(st, 50)
Run the code above in your browser using DataLab