Learn R Programming

sits (version 1.1.0)

plot.classified_image: Plot classified images

Description

plots a classified raster using ggplot.

Usage

# S3 method for classified_image
plot(
  x,
  y,
  ...,
  tiles = NULL,
  title = "Classified Image",
  legend = NULL,
  palette = "Spectral",
  rev = TRUE
)

Value

A plot object produced by the ggplot2 package with a color maps, where each pixel has the color associated to a label, as defined by the legend parameter.

Arguments

x

Object of class "classified_image".

y

Ignored.

...

Further specifications for plot.

tiles

Tiles to be plotted.

title

Title of the plot.

legend

Named vector that associates labels to colors.

palette

Alternative palette that uses grDevices::hcl.pals().

rev

Invert the order of hcl palette?

Author

Gilberto Camara, gilberto.camara@inpe.br

Examples

Run this code
if (sits_run_examples()) {
    # select a set of samples
    samples_ndvi <- sits_select(samples_modis_4bands, bands = c("NDVI"))
    # create a random forest model
    rfor_model <- sits_train(samples_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",
        data_dir = data_dir,
        delim = "_",
        parse_info = c("X1", "X2", "tile", "band", "date")
    )
    # classify a data cube
    probs_cube <- sits_classify(data = cube, ml_model = rfor_model)
    # label cube with the most likely class
    label_cube <- sits_label_classification(probs_cube)
    # plot the resulting classified image
    plot(label_cube)
}

Run the code above in your browser using DataLab