lucC_save_GeoTIFF: Save a RasterBrick reclassified in Folder

Description Usage Arguments Value Author(s) Examples

View source: R/lucC_save_raster_GeoTIFF.R

Description

Save new_raster reclassified in a diretory defined by user. NOTE: Applied only when update a raster with new values, after had applied the function lucC_raster_update.

Usage

1
2
lucC_save_GeoTIFF(raster_obj = NULL, data_mtx = NULL,
path_raster_folder = NULL, as_RasterBrick = FALSE)

Arguments

raster_obj

Raster. A raster brick with classified images

data_mtx

Matrix. A matrix with pixel replaced, can be obtined using lucC_update_raster()

path_raster_folder

Character. Name a path folder to save raster images data. If doesn't exist, a new directory is created

as_RasterBrick

Boolean. If FALSE, each layer will be saved in separate file. If TRUE, write a RasterBrick in a file. Default is FALSE.

Value

Raster in geotiff format to open using SIG

Author(s)

Adeline M. Maciel

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Not run: 
library(lucCalculus)

file <- c(system.file("extdata/raster/rasterSample.tif", package = "lucCalculus"))
rb_class <- raster::brick(file)
my_label <- c("Degradation", "Fallow_Cotton", "Forest", "Pasture", "Soy_Corn", "Soy_Cotton",
              "Soy_Fallow", "Soy_Millet", "Soy_Sunflower", "Sugarcane", "Urban_Area", "Water")
my_timeline <- c("2001-09-01", "2002-09-01", "2003-09-01", "2004-09-01", "2005-09-01",
                 "2006-09-01", "2007-09-01", "2008-09-01", "2009-09-01", "2010-09-01",
                 "2011-09-01", "2012-09-01", "2013-09-01", "2014-09-01", "2015-09-01",
                 "2016-09-01")

a <- lucC_pred_recur(raster_obj = rb_class, raster_class = "Forest",
                     time_interval1 = c("2001-09-01","2001-09-01"),
                     time_interval2 = c("2002-09-01","2016-09-01"),
                     label = my_label, timeline = my_timeline)

# update original RasterBrick with new class
num_label <- length(my_label) + 1
rb_class_new <- lucC_raster_update(raster_obj = rb_class,
                                   data_mtx = a,
                                   timeline = my_timeline,
                                   class_to_replace = "Forest",  # the same class previously
                                   new_pixel_value = num_label)  # new pixel value

lucC_plot_bar_events(data_mtx = rb_class_new, pixel_resolution = 232, custom_palette = FALSE)

# save the update matrix as GeoTIFF RasterBrick
lucC_save_GeoTIFF(raster_obj = rb_class, data_mtx = rb_class_new,
                  path_raster_folder = paste0(getwd(), "/updatedRasterRECUR", sep = ""),
                  as_RasterBrick = FALSE )


## End(Not run)

ammaciel/lucCalculus documentation built on June 13, 2020, 4:57 a.m.