Description Usage Arguments Details Value Memory Issues See Also Examples
View source: R/setRasclassData.R
This function adds data from a dataframe to an existing rasclass-class
object.
1 2 3 |
newdata |
A data frame containing raster cell values in its columns. |
object |
An optional rasclass object where the data should be updated to, a new object is created if not specified. |
ncols |
The number of columns of the raster grid. Optional if the values are already specified in the rasclass object. |
nrows |
The number of rows of the raster grid. Optional if the values are already specified in the rasclass object. |
xllcorner |
Coordinates of the X coordinate of the lower left corner. Optional if the values are already specified in the rasclass object. |
yllcorner |
Coordinates of the Y coordinate of the lower left corner. Optional if the values are already specified in the rasclass object. |
cellsize |
The cell size of the grid. Optional if the values are already specified in the rasclass object. |
NAvalue |
The value in the raster that represents NA values. Optional if the values are already specified in the rasclass object. |
samplename |
Optional name of the column in the input data frame that will be used as sample data. The default is 'sample'. |
This function adds data from a dataframe to a rasclass object for subsequent classification using the classifiers from the rasclass package. Similar to the readRasterFolder
, the name of the column containing the sample data has to be specified. The default sample column name is "sample".
The data in the input dataframe is assumed to be from raster files with the same projection, grid size and location. For ascii files this is equivalent to having an identical header in all the layers. If the common header has not been specified in the gridSkeleton
slot of the input object before, the values have to be given as arguments to the function.
A rasclass-class
object containing the loaded data as a dataframe in the data
slot.
The setRasclassData
function only keeps track of data raster cells that have an observed value (non-NA
) in every column of the input dataframe provided. The resulting grid structure will be retained in the gridSkeleton slot.
rasclass-package
,
rasclass-class
,
rasclassRaster-class
,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # For this example, create artificial data
mysample <- c(rep(rep(c(1,2), each = 25), 25), rep(rep(c(3,4), each = 25), 25))
mysample <- mysample + sample(c(0, NA), 2500, replace = TRUE, prob = c(1, 10))
myvar1 <- rep(1:50, each = 50) + rnorm(2500, 0, 5)
myvar2 <- rep(rep(1:50), 50) + rnorm(2500, 0, 5)
newdata <- data.frame(mysample, myvar1, myvar2)
# Prepare a rasclass object using the dataframe and specifying raster properties
object <- new('rasclass')
object <- setRasclassData(newdata, ncols = 50, nrows = 50,
xllcorner = 0, yllcorner = 0, cellsize = 1, NAvalue = -9999,
samplename = 'mysample')
# Summarize the rasclass object
summary(object)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.