Learn R Programming

sits (version 1.2.0)

sits_mosaic: Mosaic classified cubes

Description

Creates a mosaic of all tiles of a classified cube. It is possible to provide a roi to cropping the mosaic. If the roi parameter is supplied, each tile will be cropped in parallel and the multicores parameter can be used to define how many tiles will be cropped simultaneously.

Usage

sits_mosaic(
  cube,
  crs,
  roi = NULL,
  multicores = 2,
  output_dir = getwd(),
  version = "v1",
  progress = TRUE
)

Value

a sits cube with only one tile.

Arguments

cube

A sits data cube.

crs

A target coordinate reference system of raster mosaic. The provided crs could be a character (e.g, "EPSG:4326" or a proj4string), or a a numeric with the EPSG code (e.g. 4326).

roi

Region of interest (see below).

multicores

Number of cores that will be used to crop the images in parallel.

output_dir

Directory for output images.

version

Version of resulting image (in the case of multiple tests)

progress

Show progress bar? Default is TRUE.

Author

Felipe Carvalho, felipe.carvalho@inpe.br

Rolf Simoes, rolf.simoes@inpe.br

Examples

Run this code
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",
        data_dir = data_dir,
        delim = "_",
        parse_info = c("X1", "tile", "band", "date")
    )
    # classify a data cube
    probs_cube <- sits_classify(data = cube, ml_model = rfor_model)
    # smooth the probability cube using Bayesian statistics
    bayes_cube <- sits_smooth(probs_cube)
    # label the probability cube
    label_cube <- sits_label_classification(bayes_cube)
    # create roi
    roi <- sf::st_sfc(
        sf::st_polygon(
          list(rbind(
            c(-55.64768, -11.68649),
            c(-55.69654, -11.66455),
            c(-55.62973, -11.61519),
            c(-55.64768, -11.68649)))), crs = 4326
    )
    # crop and mosaic classified image
    mosaic_cube <- sits_mosaic(
             cube = label_cube,
             roi = roi,
             crs = 4326
    )
}

Run the code above in your browser using DataLab