Extract {ursa} | R Documentation |
This operator is used to get single band or subset of bands from multi-band ursaRaster
object. Another purpose is get portions of data including data reading from files.
## S3 method for class 'ursaRaster' x[i, j, ..., drop = FALSE]
x |
|
i |
Integer or character. If integer, then band index, specifying bands to extract. If character, either list of band names or charater sting for |
j |
Integer. Line index, specifying lines to extract. |
... |
Mentioned for consistence with internal generic function |
drop |
Not used. For consistence with generic function. |
Operator \sQuote{[}
is high-level implementation for data reading. If x$value
item is not applicable, then value of ursaRaster
is not in memory. In this case the controlled by i
and j
portion is read to memory. If both i
and j
are missing, then x[]
reads all values from file.
x[,j]
is appropriate for time series analysis and processing in the case bands have relation to temporal observation. Use regrid
for geographical subset and cropping.
ursaRaster
object with extracter bands. Values ($value
item) are in memory.
It is not allowed to read simultaneously portion of bands and portion of lines from file, e.g.,
x <- open_envi(fname) y <- x[2:3,10:20] close(x)
Such brunch is not implemented in code. You use one of the followed tricks:
x <- open_envi(fname) y <- x[2:3][,20:30] close(x)
or
x <- open_envi(fname) y <- x[,20:30][2:3] close(x)
Nikita Platonov platonov@sevin.ru
session_grid(NULL) ## Prepare session_grid(regrid(mul=1/8)) a <- pixelsize() w <- c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday" ,"MondayAgain") b <- rep(a/mean(a),length(w))+seq(length(w))-1 bandname(b) <- w nr <- ursa_rows(b) bottom <- (as.integer(nr/2)):nr write_envi(b,"tmp1",compress=FALSE,interleave="bil") ## Extract print(b["Monday",regexp=TRUE]) print(b["Monday",regexp=FALSE]) print(b["s"]) print(b["^s"]) d1 <- b[6,bottom] rm(b) ## Read from file b <- open_envi("tmp1") print(b[]) print(b[-c(6:8)]) d2 <- b[,bottom][6] ## don't use b[6,bottom] close(b) envi_remove("tmp1") ## Compare print(d1) print(d2)