Remotely sensed multi-spectral data is represented by a combination of spatial position (pixel number and line number) and band. The data storage scheme for multi-band images is classified into the following three types, described below:
So let’s download a Sentinel 2 multi-spectral image and go over these schema’s. We will use sen2r
package to download the data. First install/load the package
rm(list=ls(all=TRUE))
if(!require(sen2r))install.packages('sen2r')
## Loading required package: sen2r
## Registered S3 method overwritten by 'geojsonsf':
## method from
## print.geojson geojson
## Welcome to sen2r. To use the package from a GUI, launch
## > sen2r()
## Documentation: https://sen2r.ranghetti.info
## Help and bug report: https://github.com/ranghetti/sen2r/issues
library(sen2r)
Let us use a GUI to donwload sentinel 2 data.
#sen2r()
Next lets save our login credentials by running the command write_scihub_login("my_user", "my_password")
where ‘my_user’ is your username and ‘my_password’ the corresponding scihub account password. If so wish you can use an interactive GUI using the command sen2r()
but ensure to install the following packages mapedit
, shinyFiles
, shinydashboard
, and shinyWidgets
.
#write_scihub_login("my_user", "my_password")
#
# path <- getwd()
# aoi <- paste0(path,"/data/JKUAT.json")
# out_dir <- paste0(path,"/data/")
# safe_dir <- dir.create(paste0(path,"/safe/"),recursive = TRUE)
#
# out1 <- sen2r(
# gui = FALSE,
# extent = system.file(aoi, package = "sen2r"),
# extent_name = 'JKUAT',
# timewindow = c("2021-01-01", "2021-01-12"),
# list_prods = "BOA",
# list_rgb = "RGB832B",
# path_l1c = safe_dir,
# path_l2a = safe_dir,
# path_out = out_dir,
# clip_on_extent = TRUE,
# extent_as_mask = TRUE,
# overwrite =TRUE
# )
#
#
# safe_folder <- tempfile(pattern = "safe_")
# out_folder_1 <- tempfile(pattern = "Example1_")
# sel_tile_1 <- s2tiles_kaz[sample(nrow(s2tiles_kaz),1),] %>%
# sf::st_transform(3857)
# sel_tile_1$tile_id
# ## [1] "40TET"
# sel_extent_1 <- sf::st_centroid(sel_tile_1) %>% st_buffer(5e3)
# out1 <- sen2r(
# gui = FALSE,
# extent = sel_extent_1,
# timewindow = c("2018-02-21", "2018-03-02"),
# list_rgb = "RGB432T",
# path_l1c = safe_dir,
# path_l2a = safe_dir,
# path_out = out_dir,
# log = log_path_1 <- tempfile()
# )
Luigi Ranghetti and Mirco Boschetti and Francesco Nutini and Lorenzo Busetto (2020). sen2r: An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. doi: 10.1016/j.cageo.2020.104473, URL: https://sen2r.ranghetti.info.
Created 14th May 2021 Copyright © Benson Kenduiywo, Inc. All rights reserved.