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)
}
Run the code above in your browser using DataLab