Learn R Programming

sits (version 1.5.3)

sits_get_class: Get values from classified maps

Description

Given a set of lat/long locations and a classified cube, retrieve the class of each point. This function is useful to obtain values from classified cubes for accuracy estimates.

Usage

sits_get_class(cube, samples)

# S3 method for default sits_get_class(cube, samples)

# S3 method for csv sits_get_class(cube, samples)

# S3 method for shp sits_get_class(cube, samples)

# S3 method for sf sits_get_class(cube, samples)

# S3 method for sits sits_get_class(cube, samples)

# S3 method for data.frame sits_get_class(cube, samples)

Value

A tibble of with columns <longitude, latitude, start_date, end_date, label>.

Arguments

cube

Classified data cube.

samples

Location of the samples to be retrieved. Either a tibble of class "sits", an "sf" object, the name of a shapefile or csv file, or a data.frame with columns "longitude" and "latitude"

Author

Gilberto Camara, gilberto.camara@inpe.br

Examples

Run this code
if (sits_run_examples()) {
    # create a random forest model
    rfor_model <- sits_train(samples_modis_ndvi, sits_rfor())
    # create a data cube from local files
    data_dir <- system.file("extdata/raster/mod13q1", package = "sits")
    cube <- sits_cube(
        source = "BDC",
        collection = "MOD13Q1-6.1",
        data_dir = data_dir
    )
    # classify a data cube
    probs_cube <- sits_classify(
        data = cube, ml_model = rfor_model, output_dir = tempdir()
    )
    # plot the probability cube
    plot(probs_cube)
    # smooth the probability cube using Bayesian statistics
    bayes_cube <- sits_smooth(probs_cube, output_dir = tempdir())
    # plot the smoothed cube
    plot(bayes_cube)
    # label the probability cube
    label_cube <- sits_label_classification(
        bayes_cube,
        output_dir = tempdir()
    )
    # obtain the a set of points for sampling
    ground_truth <- system.file("extdata/samples/samples_sinop_crop.csv",
        package = "sits"
    )
    # get the classification values for a selected set of locations
    labels_samples <- sits_get_class(label_cube, ground_truth)
}

Run the code above in your browser using DataLab