plot.class_cube: Plot classified images

View source: R/sits_plot.R

plot.class_cubeR Documentation

Plot classified images

Description

plots a classified raster using ggplot.

Usage

## S3 method for class 'class_cube'
plot(
  x,
  y,
  ...,
  tile = x[["tile"]][[1]],
  title = "Classified Image",
  legend = NULL,
  palette = "Spectral",
  scale = 1,
  max_cog_size = 1024
)

Arguments

x

Object of class "class_cube".

y

Ignored.

...

Further specifications for plot.

tile

Tile to be plotted.

title

Title of the plot.

legend

Named vector that associates labels to colors.

palette

Alternative RColorBrewer palette

scale

Relative scale (0.4 to 1.0) that controls

max_cog_size

Maximum size of COG overviews (lines or columns)

Value

A color map, where each pixel has the color associated to a label, as defined by the legend parameter.

Note

The following optional parameters are available to allow for detailed control over the plot output:

  • first_quantile: 1st quantile for stretching images (default = 0.05)

  • last_quantile: last quantile for stretching images (default = 0.95)

  • graticules_labels_size: size of coordinates labels (default = 0.8)

  • legend_title_size: relative size of legend title (default = 1.0)

  • legend_text_size: relative size of legend text (default = 1.0)

  • legend_bg_color: color of legend background (default = "white")

  • legend_bg_alpha: legend opacity (default = 0.5)

Author(s)

Gilberto Camara, gilberto.camara@inpe.br

Examples

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()
    )
    # label cube with the most likely class
    label_cube <- sits_label_classification(
        probs_cube,
        output_dir = tempdir()
    )
    # plot the resulting classified image
    plot(label_cube)
}

sits documentation built on Sept. 11, 2024, 6:36 p.m.