Learn R Programming

sits (version 1.4.1)

plot.segments: Plot Segments

Description

Plot RGB raster cube

Usage

# S3 method for segments
plot(
  x,
  ...,
  tile = NULL,
  legend = NULL,
  color_palette = "Spectral",
  tmap_options = NULL
)

Value

A plot object with an RGB image or a B/W image on a color scale using the pallete

Arguments

x

Object of class "segments".

...

Further specifications for plot.

tile

Tile to be plotted.

legend

Named vector that associates labels to colors.

color_palette

Alternative RColorBrewer palette

tmap_options

List with optional tmap parameters tmap_max_cells (default: 1e+06) tmap_graticules_labels_size (default: 0.7) tmap_legend_title_size (default: 1.5) tmap_legend_text_size (default: 1.2) tmap_legend_bg_color (default: "white") tmap_legend_bg_alpha (default: 0.5)

Author

Gilberto Camara, gilberto.camara@inpe.br

Examples

Run this code
if (sits_run_examples()) {
data_dir <- system.file("extdata/raster/mod13q1", package = "sits")

cube <- sits_cube(
    source = "BDC",
    collection = "MOD13Q1-6",
    data_dir = data_dir
)

# segment the image
segments <- sits_segment(
    cube = cube,
    tile = "012010",
    bands = "NDVI",
    date = sits_timeline(cube)[1],
    seg_fn = sits_slic(step = 10)
)
# create a classification model
rfor_model <- sits_train(samples_modis_ndvi, sits_rfor())
# get the average value per segment
samples_seg <- sits_get_data(
    cube = cube,
    samples = segments
)
# classify the segments
seg_class <- sits_classify(
    data = samples_seg,
    ml_model = rfor_model
)
# add a column to the segments by class
sf_seg <- sits_join_segments(
    data = seg_class,
    segments = segments
)
plot(sf_seg)
}

Run the code above in your browser using DataLab