Learn R Programming

sits (version 1.5.3)

sits_apply: Apply a function on a set of time series

Description

Apply a named expression to a sits cube or a sits tibble to be evaluated and generate new bands (indices). In the case of sits cubes, it creates a new band in output_dir.

Usage

sits_apply(data, ...)

# S3 method for sits sits_apply(data, ...)

# S3 method for raster_cube sits_apply( data, ..., window_size = 3L, memsize = 4L, multicores = 2L, normalized = TRUE, output_dir, progress = TRUE )

# S3 method for derived_cube sits_apply(data, ...)

# S3 method for default sits_apply(data, ...)

Value

A sits tibble or a sits cube with new bands, produced according to the requested expression.

Arguments

data

Valid sits tibble or cube

...

Named expressions to be evaluated (see details).

window_size

An odd number representing the size of the sliding window of sits kernel functions used in expressions (for a list of supported kernel functions, please see details).

memsize

Memory available for classification (in GB).

multicores

Number of cores to be used for classification.

normalized

Does the expression produces a normalized band?

output_dir

Directory where files will be saved.

progress

Show progress bar?

Kernel functions available

  • w_median(): returns the median of the neighborhood's values.

  • w_sum(): returns the sum of the neighborhood's values.

  • w_mean(): returns the mean of the neighborhood's values.

  • w_sd(): returns the standard deviation of the neighborhood's values.

  • w_min(): returns the minimum of the neighborhood's values.

  • w_max(): returns the maximum of the neighborhood's values.

  • w_var(): returns the variance of the neighborhood's values.

  • w_modal(): returns the modal of the neighborhood's values.

Author

Rolf Simoes, rolfsimoes@gmail.com

Felipe Carvalho, felipe.carvalho@inpe.br

Gilberto Camara, gilberto.camara@inpe.br

Examples

Run this code
if (sits_run_examples()) {
    # get a time series
    # Apply a normalization function

    point2 <-
        sits_select(point_mt_6bands, "NDVI") |>
        sits_apply(NDVI_norm = (NDVI - min(NDVI)) / (max(NDVI) - min(NDVI)))

    # Example of generation texture band with variance
    # 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
    )

    # Generate a texture images with variance in NDVI images
    cube_texture <- sits_apply(
        data = cube,
        NDVITEXTURE = w_median(NDVI),
        window_size = 5,
        output_dir = tempdir()
    )
}

Run the code above in your browser using DataLab