# NOT RUN {
# Define product name
s2_examplenames <- c(
"S2A_MSIL1C_20190723T101031_N0208_R022_T32TNS_20190723T121220.SAFE",
"S2A_MSIL1C_20190723T101031_N0208_R022_T32TNR_20190723T121220.SAFE"
)
# Return the information retrievable from the file names (files are not scanned)
safe_getMetadata(s2_examplenames, info="nameinfo")
# Return some specific information without scanning files
safe_getMetadata(s2_examplenames, info=c("level", "id_tile"))
# Return a single information without scanning files
# (in this case, the default output is a vector instead than a data.table)
safe_getMetadata(s2_examplenames, info="level")
# Check if the products are valid existing SAFE archives
safe_isvalid(s2_examplenames)
# Check if the product names are valid SAFE names
safe_isvalid(s2_examplenames, check_file = FALSE)
safe_isvalid("invalid_safe_name.SAFE", check_file = FALSE)
# }
# NOT RUN {
# Download a sample SAFE archive (this can take a while)
s2_exampleurl <- c(
"S2A_MSIL1C_20190723T101031_N0208_R022_T32TNS_20190723T121220.SAFE" =
paste0("https://scihub.copernicus.eu/apihub/odata/v1/",
"Products('19bbde60-992b-423d-8dea-a5e0ac7715fc')/$value")
)
s2_download(s2_exampleurl, outdir=tempdir())
s2_examplepath <- file.path(tempdir(), names(s2_exampleurl))
# Return all the available information
safe_getMetadata(s2_examplepath)
# Return some specific information
safe_getMetadata(s2_examplepath, info=c("clouds", "direction"))
# Return a single information
safe_getMetadata(s2_examplepath, info="nodata_value")
# Check if the downloaded SAFE is valid
safe_isvalid(s2_examplepath)
# Delete it if it is not recognised
rm_invalid_safe(s2_examplepath)
# }
Run the code above in your browser using DataLab