as.data.frame | R Documentation |
as.data.frame
reorganizes ursaRaster
object into data frame, where first two columns (x
and y
) are coordinates of cells, and the rest columns are cell values.
## S3 method for class 'ursaRaster'
as.data.frame(x, ...)
# non-public
.as.data.frame(obj, band = FALSE, id = FALSE, na.rm = TRUE, all.na = FALSE,
col.names = NULL)
x , obj |
Object of class | ||||||||||||||||||
... |
Set of arguments, which are recognized via their names (using regular expressions) and classes. Passed to non-public
| ||||||||||||||||||
band |
Logical. If | ||||||||||||||||||
id |
Logical. If | ||||||||||||||||||
na.rm |
Logical. If | ||||||||||||||||||
all.na |
Logical. If | ||||||||||||||||||
col.names |
Character vector or |
The structure of voxel is kept. The number of rows for band=TRUE
is equal to the number of rows for band=FALSE
multiplied to number of bands. To extract all numeric data with destroying of voxel, you may use followed code:subset(as.data.frame(obj,band=TRUE),!is.na(z))
.
Data frame.
If band=TRUE
then
x |
Horizontal coordinate of cell's midpoint |
y |
Vertical coordinate of cell's midpoint |
z |
Value |
band |
Band as a |
id |
Optional. Unique number for |
If band=FALSE
then
x |
Horizontal coordinate of cell's midpoint |
y |
Vertical coordinate of cell's midpoint |
... |
Additional columns. Names of columns are names of bands. Values of columns are values of corresponded bands. |
If ursaRaster
is projected, then data frame has additional attribute attr(...,"proj")
with value of PROJ.4 string.
Nikita Platonov platonov@sevin.ru
session_grid(NULL)
session_grid(regrid(res=50000,lim=c(-1200100,-1400800,1600900,1800200)))
a0 <- ursa_dummy(nband=3,min=0,max=100)
a0[a0<30 | a0>70] <- NA
names(a0) <- c("x","y","z")
print(a0)
b0 <- as.data.frame(a0)
session_grid(NULL)
a1 <- as.ursa(b0)
print(a1-a0)
session_grid(NULL)
session_grid(regrid(res=5800000))
set.seed(352)
a2 <- as.integer(ursa_dummy(nband=2,min=0,max=100))
a2[a2>50] <- NA
print(a2)
print(b1 <- as.data.frame(a2,na.rm=FALSE))
print(b2 <- as.data.frame(a2,na.rm=TRUE))
print(b3 <- as.data.frame(a2,all.na=TRUE))
print(b4 <- as.data.frame(a2,band=TRUE,na.rm=FALSE))
print(b5 <- as.data.frame(a2,band=TRUE,all.na=FALSE))
print(b6 <- as.data.frame(a2,band=TRUE,all.na=TRUE))
print(b7 <- as.data.frame(a2,band=TRUE,all.na=TRUE,id=TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.