[R-sig-Geo] raster package

Agustin Lobo alobolistas at gmail.com
Wed May 20 15:44:33 CEST 2009


Robert,

But then rc would be a large R object? I mean, assuming
mytiffile.tif is large (> 8000x8000 in my case).

I've tried:

 > CATLC <- 
raster("/media/Transcend/Mario/BCNmetrop/GEODATA_BCN/CATLCLU2002/CATLCLU2002.tif")
 > class(CATLC)
[1] "RasterLayer"
attr(,"package")
[1] "raster"
 > summary(CATLC)
Cells: 78062352
values not in memory

which is ok but then:

 > rectable <- read.table("reclas.txt", sep="=",na.strings = "end",nrows=23)
 > rectable <- cbind(rectable[,1],rectable[,1],rectable[,2])
 > CATLU1 <- reclass(CATLC,rectable, filetype="GTiff", file="CATLU1.tif")

The last command seems to take up all memory. The system slows down as 
if CATLU1
had been read into an R object.

Am I doing something wrong?

Agus

Robert Hijmans wrote:
> Agus,
>
>   
>> Is there a way
>> of assigning the tif file to an R raster object and then just use
>> reclass() and R would
>> read the file by pieces as needed? That's what I would like to...
>>     
>
> That is exactly what is intended with reclass(). Something like this :
>
> r <- raster('mytiffile.tif')
> m <- matrix(0,1000,1, 1000, Inf, NA, ncol=2)
> rc <- reclass(r, m, ...)
>
> Robert
>
> On Tue, May 19, 2009 at 1:36 AM, Agustin Lobo <alobolistas at gmail.com> wrote:
>   
>> I have to reclassify a large (> 8000x8000 pixels) geotif raster. I normally
>> would do it through grass (or saga) but would like to try the raster
>> package in R.
>> The problem is that I'm a bit confused on how to do it. My understanding
>> of the package
>> is that it provides a way to operate in the rasters by pieces, not having
>> to read the whole thing into memory. I've seen there's a function reclass()
>> but how do I actually read the raster? If I use readAll() this is going
>> to be as
>> using readGDAL() directly, so this is not the way. Do I have to use
>> a for() of readRows(), then reclass()? This seems a bit low-level. Is
>> there a way
>> of assigning the tif file to an R raster object and then just use
>> reclass() and R would
>> read the file by pieces as needed? That's what I would like to...
>>
>> Agus
>>
>>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
>>     
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>



More information about the R-sig-Geo mailing list