[R-sig-Geo] extracting time series data from a raster brick of AVHRR satellite data
Robert Hijmans
r.hijmans at gmail.com
Wed Jul 27 21:23:44 CEST 2011
Jan,
> Any advice? Should I do this via Python or can this be done via R but more
> efficient?
Interesting problem, that I had not noticed before. I think this is because
a loop that can perhaps be omitted or else perhaps needs to move to a C
routine. I need to investigate that. For now, for speed, either read the
values into memory (if possible; perhaps a spatial subset, via 'crop'), or
perhaps use ncdf files (see example below).
> library(raster)
Loading required package: sp
raster version 1.9-3 (27-July-2011)
> b <- brick(nc=10, nr=10, nl=648)
> b <- setValues(b, matrix(rep(1:100, 648), nc=648))
> system.time(v <- b[1])
user system elapsed
0 0 0
>
> d <- writeRaster(b, 'test.grd', overwrite=TRUE)
> inMemory(d)
[1] FALSE
> system.time(v <- d[1]) # too slow
user system elapsed
61.54 0.14 61.98
>
> d <- readAll(d)
> inMemory(d)
[1] TRUE
> system.time(v <- d[1]) # OK
user system elapsed
0 0 0
>
> e <- writeRaster(b, 'test.nc', overwrite=TRUE)
Loading required package: ncdf
> inMemory(e)
[1] FALSE
> system.time(v <- e[1]) # OK
user system elapsed
0.01 0.00 0.02
>
Robert
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/extracting-time-series-data-from-a-raster-brick-of-AVHRR-satellite-data-tp6622055p6627415.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list