Learn R Programming

sits (version 1.5.3)

sits_view: 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 sits sits_view(x, ..., legend = NULL, palette = "Set3", radius = 10L, add = FALSE)

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

# S3 method for som_map sits_view( x, ..., id_neurons, legend = NULL, palette = "Harmonic", radius = 10L, add = FALSE )

# S3 method for raster_cube sits_view( x, ..., band = NULL, red = NULL, green = NULL, blue = NULL, tiles = x[["tile"]][[1L]], dates = NULL, palette = "RdYlGn", rev = FALSE, opacity = 0.85, max_cog_size = 2048L, first_quantile = 0.02, last_quantile = 0.98, leaflet_megabytes = 64L, add = FALSE )

# S3 method for uncertainty_cube sits_view( x, ..., tiles = x[["tile"]][[1L]], legend = NULL, palette = "RdYlGn", rev = FALSE, opacity = 0.85, max_cog_size = 2048L, first_quantile = 0.02, last_quantile = 0.98, leaflet_megabytes = 64L, add = FALSE )

# S3 method for class_cube sits_view( x, ..., tiles = x[["tile"]], legend = NULL, palette = "Set3", version = NULL, opacity = 0.85, max_cog_size = 2048L, leaflet_megabytes = 32L, add = FALSE )

# S3 method for probs_cube sits_view( x, ..., tiles = x[["tile"]][[1L]], label = x[["labels"]][[1L]][[1L]], legend = NULL, palette = "YlGn", rev = FALSE, opacity = 0.85, max_cog_size = 2048L, first_quantile = 0.02, last_quantile = 0.98, leaflet_megabytes = 64L, add = FALSE )

# S3 method for vector_cube sits_view( x, ..., tiles = x[["tile"]][[1L]], seg_color = "yellow", line_width = 0.5, add = FALSE )

# S3 method for class_vector_cube sits_view( x, ..., tiles = x[["tile"]][[1L]], seg_color = "yellow", line_width = 0.2, version = NULL, legend = NULL, palette = "Set3", opacity = 0.85, add = FALSE )

# S3 method for default sits_view(x, ...)

Value

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

Arguments

x

Object of class "sits", "data.frame", "som_map", "raster_cube", "probs_cube", "vector_cube", or "class cube".

...

Further specifications for sits_view.

legend

Named vector that associates labels to colors.

palette

Color palette from RColorBrewer

radius

Radius of circle markers

add

Add image to current leaflet

id_neurons

Neurons from the SOM map to be shown.

band

Single band for viewing false color 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.

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)

version

Version name (to compare different classifications)

label

Label to be plotted (in case of probs cube)

seg_color

Color for segment boundaries

line_width

Line width for segments (in pixels)

Author

Gilberto Camara, gilberto.camara@inpe.br

Examples

Run this code
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
    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)
}

Run the code above in your browser using DataLab