# NOT RUN {
# Define product name
s2_examplenames <- c(
"S2A_MSIL1C_20170703T101021_N0205_R022_T32TNS_20170703T101041.SAFE",
"S2A_MSIL2A_20170703T101021_N0205_R022_T32TNR_20170703T101041.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 <- paste0("https://scihub.copernicus.eu/apihub/odata/v1/",
"Products(\'5f590bcb-ee55-4a20-8e75-bde99f5b93d4\')/$value")
names(s2_exampleurl) <- "S2A_MSIL1C_20170703T101021_N0205_R022_T32TNS_20170703T101041.SAFE"
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