
Last chance! 50% off unlimited learning
Sale ends in
senMosaic
merges the Sentinel-2 imagery that covers a region of interest
on the same dates.
senMosaic(
src,
AppRoot,
region = NULL,
out.name = "outfile",
verbose = FALSE,
gutils = TRUE,
overwrite = FALSE,
...
)
the path of the folder with the Sentinel images in GTiff format.
the directory to save the mosaicked images.
a Spatial*
, projected raster*
, or sf
class object
defining the area of interest.
the name of the folder that stores the outputs. By default, <U+201C>outfile<U+201D> is assigned.
logical argument. If TRUE
, the function prints the
running steps and warnings.
logical argument. If TRUE
, the function uses `GDAL'
utilities for mosaicking.
logical argument. If TRUE
, overwrites the existing
images with the same name.
arguments for nested functions:
pathrow
a list
of vectors with the path and row numbers
of the tiles concerning the region of interest. This argument is mandatory
if region
is not defined.
bFilter
a vector with the bands to be mosaicked. If not
supplied, all bands are mosaicked.
dates
a vector with the capturing dates being considered
for mosaicking. If not supplied, all dates are mosaicked.
this function does not return anything. It saves the imagery in the
AppRoot
directory.
The function mosaics the imagery in the src
folder. The folder can
hold GTiff images from several tiles, dates and bands. When only a subset
dates has to be mosaicked, the dates should be provided through the argument
dates
. The dates must be provided as a Date
class object.For
further details about the bFilter
argument, go to the
senDownload
function. Once mosaicked, the images can be cropped
to fit the region
(optional). The region
can be defined in any
coordinate reference system, since senMosaic
automatically reproject
the extent to match the projection of the image. The outputs will be placed
in the AppRoot
directory, under the folder named as out.name
.
If no name is provided, the folder is named <U+201C>outfile<U+201D>.
# NOT RUN {
# load a spatial polygon object of Navarre
data(ex.navarre)
# main output directory
wdir <- file.path(tempdir(),"Path_for_downloading_folder")
print(wdir)
# download Sentinel-2 images
senDownSearch(startDate = as.Date("2018210", "%Y%j"),
endDate = as.Date("2018218", "%Y%j"),
platform = "Sentinel-2",
extent = ex.navarre,
product = "S2MSI1C",
pathrow = c("R094"),
username = "username",
password = "password",
AppRoot = wdir)
# folder with the unzipped images
wdir.sen <- file.path(wdir, "Sentinel-2")
wdir.sen.unzip <- file.path(wdir.sen, "unzip")
# mosaic the Sentinel-2 images
senMosaic(wdir.sen.unzip,
AppRoot = wdir.sen,
gutils = TRUE,
out.name = "Navarre")
wdir.sen <- file.path(wdir.sen,"Navarre")
# load and plot a Sentinel-2 image
files.sen <- list.files(wdir.sen, pattern = "\\.tif$", full.names = TRUE ,recursive = TRUE)
# print Sentinel-2 bands
getRGISToolsOpt("SEN2BANDS")
file.sen.rgb <- stack(files.sen[grepl("TCI",files.sen)][1])
plotRGB(file.sen.rgb)
# }
Run the code above in your browser using DataLab