sits_segment {sits} | R Documentation |
Segment an image
Description
Apply a spatial-temporal segmentation on a data cube based on a user defined segmentation function. The function applies the segmentation algorithm "seg_fn" to each tile.
Segmentation uses the following steps:
Create a regular data cube with
sits_cube
andsits_regularize
;Run
sits_segment
to obtain a vector data cube with polygons that define the boundary of the segments;Classify the time series associated to the segments with
sits_classify
, to get obtain a vector probability cube;Use
sits_label_classification
to label the vector probability cube;
Usage
sits_segment(
cube,
seg_fn = sits_slic(),
roi = NULL,
impute_fn = impute_linear(),
start_date = NULL,
end_date = NULL,
memsize = 8,
multicores = 2,
output_dir,
version = "v1",
progress = TRUE
)
Arguments
cube |
Regular data cube |
seg_fn |
Function to apply the segmentation |
roi |
Region of interest (see below) |
impute_fn |
Imputation function to remove NA values. |
start_date |
Start date for the segmentation |
end_date |
End date for the segmentation. |
memsize |
Memory available for classification (in GB). |
multicores |
Number of cores to be used for classification. |
output_dir |
Directory for output file. |
version |
Version of the output (for multiple segmentations). |
progress |
Show progress bar? |
Value
A tibble of class 'segs_cube' representing the segmentation.
Note
The "roi" parameter defines a region of interest. It can be an sf_object, a shapefile, or a bounding box vector with named XY values ("xmin", "xmax", "ymin", "ymax") or named lat/long values ("lon_min", "lat_min", "lon_max", "lat_max")
Author(s)
Gilberto Camara, gilberto.camara@inpe.br
Rolf Simoes, rolf.simoes@inpe.br
Felipe Carvalho, felipe.carvalho@inpe.br
Examples
if (sits_run_examples()) {
data_dir <- system.file("extdata/raster/mod13q1", package = "sits")
# create a data cube
cube <- sits_cube(
source = "BDC",
collection = "MOD13Q1-6",
data_dir = data_dir
)
# segment the vector cube
segments <- sits_segment(
cube = cube,
output_dir = tempdir()
)
# create a classification model
rfor_model <- sits_train(samples_modis_ndvi, sits_rfor())
# classify the segments
seg_probs <- sits_classify(
data = segments,
ml_model = rfor_model,
output_dir = tempdir()
)
# label the probability segments
seg_label <- sits_label_classification(
cube = seg_probs,
output_dir = tempdir()
)
}