Description Usage Arguments Details Value Examples
senCloudMask
creates cloud masks derived from the cloud probability
band (CLDPRB
) band from the "S2MSI2A
" product.
1 2 3 4 5 6 7 8 9 | senCloudMask(
src,
AppRoot,
out.name,
resbands,
sensitivity = 50,
overwrite = FALSE,
...
)
|
src |
the path to the folder with the " |
AppRoot |
the directory where the cloud masks are saved. |
out.name |
the name of the folder that stores the outputs. If the arguemnt is not defined the folder will be named as "CloudMask". |
resbands |
a |
sensitivity |
a |
overwrite |
logical argument. If |
... |
arguments for nested functions.
|
The valid threshold range for sensitivity
is 0-100. By default,
the argument is set to 50.
this function does not return anything. It saves the cloud masks (CLD)
as GTiff files in the AppRoot
directory.
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | ## Not run:
# load a spatial polygon object of Navarre
data(ex.navarre)
# Download S2MSI1C products sensed by Sentinel-2
# between the julian days 210 and 218, 2018
wdir <- file.path(tempdir(),"Path_for_downloading_folder")
print(wdir)
senDownSearch(startDate = as.Date("2018210", "%Y%j"),
endDate = as.Date("2018218", "%Y%j"),
platform = "Sentinel-2",
extent = ex.navarre,
product = "S2MSI2A",
pathrow = c("R094"),
username = "username",
password = "password",
AppRoot = wdir)
# define the paths to the Sentinle-2 images and the
# 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")
# calculate the cloud mask
wdir.sen.navarre <- file.path(wdir.sen, "Navarre")
senCloudMask(src = wdir.sen.navarre,
resbands = "60m",
overwrite = TRUE,
sensitivity = 98,
AppRoot = wdir.sen)
# define the path for the Sentinel-2 cloud mask
wdir.sen.cloud <- file.path(wdir.sen, "CloudMask")
# select B02 images of 60 meters
tiles.sen.navarre <- list.files(wdir.sen.navarre,
full.names = TRUE,
recursive = TRUE,
pattern = "\\.tif$")
tiles.sen.navarre.b2 <- tiles.sen.navarre[grepl("B02",tiles.sen.navarre)]
tiles.sen.navarre.b2 <- tiles.sen.navarre.b2[grepl("60m",tiles.sen.navarre.b2)]
# generate a 60-meter resolution cloud mask
tiles.sen.cloud <- list.files(wdir.sen.cloud,
full.names = TRUE,
pattern = "\\.tif$")
tiles.sen.cloud.60 <- tiles.sen.cloud[grepl("60m",tiles.sen.cloud)]
# remove the cloud mask from b02 tiles
img.sen.navarre.b2 <- stack(tiles.sen.navarre.b2)
img.sen.cloud.60 <- stack(tiles.sen.cloud.60)
img.sen.navarre.b2.cloud.free <- img.sen.navarre.b2*img.sen.cloud.60
# plot b2 cloud free layers
spplot(img.sen.navarre.b2.cloud.free)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.