#' Get Sentinel 2a overlap
#'
#' This function calculates maximal overlap between sentinel scenes
#' @param inpath_sen characterstring to unzipped folder from sentinel download
#'
#' @keywords clip stack sentinel
#' @export
#' @examples
#' sen_max_overlap
#'
#' @import raster
#'
#inpath_sen <- "C:/Users/Alice/Uni/Projekte/GEDI/data/Sentinel"
sen_max_overlap <- function(inpath_sen){
########################################################################################
### settings
########################################################################################
setwd(inpath_sen)
sen_dirs <- list.dirs(inpath_sen, recursive = F)
sen_ext_lst <- lapply(sen_dirs, function(i){
# i <- sen_dirs[[1]]
basenm <- basename(i)
granule_dir <- list.dirs(paste0(basenm, "/", basenm, ".SAFE/GRANULE/"), recursive = F, full.names = F)
sen_images <- list.files(paste0(basenm, "/", basenm, ".SAFE/GRANULE/", granule_dir, "/IMG_DATA/R10m/"), full.names =T)
exmpl_img <- raster::raster(sen_images[1])
sen_ext <- extent(exmpl_img)
sen_ext_df <- data.frame(scene = basenm, xmin = xmin(sen_ext), xmax = xmax(sen_ext), ymin = ymin(sen_ext), ymax = ymax(sen_ext))
})
ext_all <- do.call(rbind, sen_ext_lst)
sen_overlap <- c(xmin = max(ext_all$xmin), xmax = min(ext_all$xmax),
ymin = max(ext_all$ymin), ymax = min(ext_all$ymax))
return(sen_overlap)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.