sits_view: View data cubes and samples in leaflet

View source: R/sits_view.R

sits_viewR Documentation

View data cubes and samples in leaflet

Description

Uses leaflet to visualize time series, raster cube and classified images

Usage

sits_view(x, ...)

## S3 method for class 'sits'
sits_view(x, ..., legend = NULL, palette = "Harmonic")

## S3 method for class 'data.frame'
sits_view(x, ..., legend = NULL, palette = "Harmonic")

## S3 method for class 'som_map'
sits_view(x, ..., id_neurons, legend = NULL, palette = "Harmonic")

## S3 method for class 'raster_cube'
sits_view(
  x,
  ...,
  band = NULL,
  red = NULL,
  green = NULL,
  blue = NULL,
  tiles = x[["tile"]][[1]],
  dates = NULL,
  class_cube = NULL,
  legend = NULL,
  palette = "RdYlGn",
  rev = FALSE,
  opacity = 0.85,
  max_cog_size = 2048,
  first_quantile = 0.02,
  last_quantile = 0.98,
  leaflet_megabytes = 64,
  seg_color = "black",
  line_width = 0.3
)

## S3 method for class 'class_cube'
sits_view(
  x,
  ...,
  tiles = x[["tile"]],
  legend = NULL,
  palette = "Spectral",
  opacity = 0.8,
  max_cog_size = 1024,
  leaflet_megabytes = 32
)

## S3 method for class 'probs_cube'
sits_view(
  x,
  ...,
  tiles = x[["tile"]],
  class_cube = NULL,
  legend = NULL,
  opacity = 0.7,
  palette = "YlGnBu"
)

## Default S3 method:
sits_view(x, ...)

Arguments

x

Object of class "sits", "data.frame", "som_map", "raster_cube" or "classified image".

...

Further specifications for sits_view.

legend

Named vector that associates labels to colors.

palette

Color palette from RColorBrewer

id_neurons

Neurons from the SOM map to be shown.

band

For plotting grey images.

red

Band for red color.

green

Band for green color.

blue

Band for blue color.

tiles

Tiles to be plotted (in case of a multi-tile cube).

dates

Dates to be plotted.

class_cube

Classified cube to be overlayed on top on image.

rev

Revert color palette?

opacity

Opacity of segment fill or class cube

max_cog_size

Maximum size of COG overviews (lines or columns)

first_quantile

First quantile for stretching images

last_quantile

Last quantile for stretching images

leaflet_megabytes

Maximum size for leaflet (in MB)

seg_color

Color for segment boundaries

line_width

Line width for segments (in pixels)

Value

A leaflet object containing either samples or data cubes embedded in a global map that can be visualized directly in an RStudio viewer.

Author(s)

Gilberto Camara, gilberto.camara@inpe.br

Examples

if (sits_run_examples()) {
    # view samples
    sits_view(cerrado_2classes)
    # create a local data cube
    data_dir <- system.file("extdata/raster/mod13q1", package = "sits")
    modis_cube <- sits_cube(
        source = "BDC",
        collection = "MOD13Q1-6.1",
        data_dir = data_dir
    )
    # view the data cube
    library(magrittr)
    sits_view(modis_cube,
        band = "NDVI"
    )
    # train a model
    rf_model <- sits_train(samples_modis_ndvi, sits_rfor())
    # classify the cube
    modis_probs <- sits_classify(
        data = modis_cube,
        ml_model = rf_model,
        output_dir = tempdir()
    )
    # generate a map
    modis_label <- sits_label_classification(
        modis_probs,
        output_dir = tempdir()
    )
    # view the classified map
    sits_view(modis_label)
    # view the classified map with the B/W image
    sits_view(modis_cube,
        band = "NDVI",
        class_cube = modis_label,
        dates = sits_timeline(modis_cube)[[1]]
    )
    # view the classified map with the RGB image
    sits_view(modis_cube,
        red = "NDVI", green = "NDVI", blue = "NDVI",
        class_cube = modis_label,
        dates = sits_timeline(modis_cube)[[1]]
    )
    # create an uncertainty cube
    modis_uncert <- sits_uncertainty(
        cube = modis_probs,
        output_dir = tempdir()
    )
    # view the uncertainty cube
    sits_view(modis_uncert, rev = TRUE)
}

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