Learn R Programming

CAWaR (version 0.0.2)

phenoCropVal: phenoCropVal

Description

Spatially explicit and phenology driven validation scheme for cropland mapping.

Usage

phenoCropVal(x, y, z)

Arguments

x

A matrix or data.frame.

y

A character vector.

z

A character vector.

Value

A list containing a set of reference profiles for each unique class in y.

Details

For each unique class in y, the function iterates through each unique element in z and keeps it for validation. Then, it calls analyseTS to derive reference profiles for each unique class in y and uses them to classify the validation samples using phenoCropClass. The final output consists of:

  • sample.validation - A logical vector with the same length of x where TRUE means it was correctly classified.

  • predicted.class - A character vector with the predicted classes for each sample.

  • sample.count - A numeric vector with the number of non-NA used for validation per sample.

  • sample.r2 - A numeric vector with the r2 value between the target sample and the selected class profile.

  • class.accuracy - A data.frame with sample count per class, precision, recall and F1-scores per unique class in y.

See Also

extractTS phenoCropClass

Examples

Run this code
# NOT RUN {
{

require(raster)
require(fieldRS)

# read raster data
r <- brick(system.file("extdata", "ndvi.tif", package="fieldRS"))

# read field data
data(fieldData)

# read reference profiles
data(referenceProfiles)

# read time series
data(fieldDataTS)
fieldDataTS <- as.data.frame(fieldDataTS$weighted.mean)

# read info. on sample spatial grouping
data(fieldDataCluster)

# derive validation results
cropVal <- phenoCropVal(fieldDataTS, fieldData$crop, fieldDataCluster$region.id)

# plot accuracy results
cropVal$accuracy.plot

# plot correctly classified polygons in red
plot(fieldData)
plot(fieldData[cropVal$sample.validation,], col="red", add=TRUE)

}
# }

Run the code above in your browser using DataLab