From db5a4e27e08727fd038b31b117f6749419bf170c Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Mon, 22 Apr 2024 16:52:10 -0300 Subject: [PATCH 01/11] add support to multiple source file --- R/api_conf.R | 52 +- R/sits_config.R | 13 +- inst/extdata/config.yml | 1425 ----------------------- inst/extdata/config_messages.yml | 2 + inst/extdata/config_source_aws.yml | 260 +++++ inst/extdata/config_source_bdc.yml | 450 +++++++ inst/extdata/config_source_cdse.yml | 143 +++ inst/extdata/config_source_deafrica.yml | 488 ++++++++ inst/extdata/config_source_hls.yml | 142 +++ inst/extdata/config_source_mpc.yml | 219 ++++ inst/extdata/config_source_sdc.yml | 144 +++ inst/extdata/config_source_usgs.yml | 81 ++ 12 files changed, 1982 insertions(+), 1437 deletions(-) create mode 100644 inst/extdata/config_source_aws.yml create mode 100644 inst/extdata/config_source_bdc.yml create mode 100644 inst/extdata/config_source_cdse.yml create mode 100644 inst/extdata/config_source_deafrica.yml create mode 100644 inst/extdata/config_source_hls.yml create mode 100644 inst/extdata/config_source_mpc.yml create mode 100644 inst/extdata/config_source_sdc.yml create mode 100644 inst/extdata/config_source_usgs.yml diff --git a/R/api_conf.R b/R/api_conf.R index 2291adf07..07200e7e8 100644 --- a/R/api_conf.R +++ b/R/api_conf.R @@ -132,7 +132,6 @@ return(yml_file) } - #' @title Return the internal configuration file (only for developers) #' @name .conf_internals_file #' @keywords internal @@ -146,6 +145,57 @@ .check_that(file.exists(yml_file)) return(yml_file) } +#' @title Return the message configuration files (only for developers) +#' @name .conf_sources_files +#' @keywords internal +#' @noRd +#' @return internal sources configuration +.conf_sources_files <- function() { + .check_set_caller(".conf_sources_files") + # list the source files configurations + package_files <- system.file("extdata", package = "sits") + yml_files <- list.files( + path = package_files, + pattern = "config_source_*", + full.names = TRUE + ) + # check that the file name is valid + purrr::map(yml_files, .check_file) + return(yml_files) +} +#' @name .conf_load_sources +#' @description Loads sources configurations +#' @keywords internal +#' @noRd +#' @return NULL, called for side effects +.conf_load_sources <- function() { + # get file paths + source_yml_files <- .conf_sources_files() + # load files + source_configs <- purrr::map(source_yml_files, function(file) { + yaml::yaml.load_file( + input = file, + merge.precedence = "override" + ) + }) + # prepare sources object + source_obj <- purrr::map(source_configs, "sources") + source_obj <- purrr::flatten(source_obj) + # prepare extras objects (e.g., token, url config) + extras_obj <- purrr::map(source_configs, function(source_config) { + source_config[["sources"]] <- NULL + source_config + }) + extras_obj <- purrr::flatten(extras_obj) + # merge objects + config_obj <- utils::modifyList(extras_obj, list( + sources = source_obj + )) + # set configurations + do.call(.conf_set_options, args = config_obj) + # done + return(invisible(NULL)) +} #' @title Return the message configuration file (only for developers) #' @name .conf_messages_file #' @keywords internal diff --git a/R/sits_config.R b/R/sits_config.R index 404408467..6bb644393 100644 --- a/R/sits_config.R +++ b/R/sits_config.R @@ -35,7 +35,6 @@ sits_config <- function(config_user_file = NULL) { .conf_load_messages() # load the internal configuration file config_internals_file <- .conf_internals_file() - # read the configuration parameters config_internals <- yaml::yaml.load_file( input = config_internals_file, @@ -43,16 +42,8 @@ sits_config <- function(config_user_file = NULL) { ) # set options defined in sits config do.call(.conf_set_options, args = config_internals) - # get and check the default configuration file path - yml_file <- .conf_file() - # read the configuration parameters - config <- yaml::yaml.load_file( - input = yml_file, - merge.precedence = "override" - ) - # set options defined in sits config - do.call(.conf_set_options, args = config) - + # load sources configuration + .conf_load_sources() # set the default color table .conf_load_color_table() # set the user options diff --git a/inst/extdata/config.yml b/inst/extdata/config.yml index 6cd5bcf0e..0965dfc2c 100644 --- a/inst/extdata/config.yml +++ b/inst/extdata/config.yml @@ -1,1427 +1,2 @@ # These are configuration parameters that can be set by users # The parameters enable access to the cloud collections - -# BDC access key -BDC_ACCESS_KEY: "vtclkRc5c874XBd0Y7NSUWuzLihnU1bHC5bbLSXfQ5" -HLS_ACCESS_URL: "machine.urs.earthdata.nasa.gov" - -sources: - BDC : - s3_class : ["bdc_cube", "stac_cube", "eo_cube", - "raster_cube"] - service : "STAC" - url : "https://brazildatacube.dpi.inpe.br/stac/" - collections : - CBERS-WFI-16D : &bdc_cb4_awfi - bands : - NDVI : &bdc_awfi_ndvi - missing_value : -9999 - minimum_value : -10000 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 64 - band_name : "NDVI" - data_type : "INT2S" - EVI : - <<: *bdc_awfi_ndvi - band_name : "EVI" - B13 : &bdc_awfi_b13 - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 64 - band_name : "BAND13" - data_type : "INT2S" - B14 : - <<: *bdc_awfi_b13 - band_name : "BAND14" - B15 : - <<: *bdc_awfi_b13 - band_name : "BAND15" - B16 : - <<: *bdc_awfi_b13 - band_name : "BAND16" - CLOUD : &bdc_awfi_cloud - bit_mask : false - band_name : "CMASK" - values : - 0 : "No Data" - 127 : "Clear Pixel" - 255 : "Cloud" - interp_values : [0, 255] - resolution : 64 - data_type : "INT1U" - satellite : "CBERS-4" - sensor : "WFI" - collection_name: "CB4-16D-2" - token_vars : ["BDC_ACCESS_KEY"] - open_data : true - open_data_token : true - metadata_search : "tile" - ext_tolerance: 0.01 - grid_system : "BDC-Large V2" - CBERS-WFI-8D : - bands : - NDVI : - <<: *bdc_awfi_ndvi - band_name : "NDVI" - EVI : - <<: *bdc_awfi_ndvi - band_name : "EVI" - B13 : - <<: *bdc_awfi_b13 - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 64 - band_name : "BAND13" - data_type : "INT2S" - B14 : - <<: *bdc_awfi_b13 - band_name : "BAND14" - B15 : - <<: *bdc_awfi_b13 - band_name : "BAND15" - B16 : - <<: *bdc_awfi_b13 - band_name : "BAND16" - CLOUD : - <<: *bdc_awfi_cloud - band_name : "CMASK" - satellite : "CBERS-4-4A" - sensor : "WFI" - collection_name: "CBERS-WFI_64_8D_LCF-1" - token_vars : ["BDC_ACCESS_KEY"] - open_data : true - open_data_token : true - metadata_search : "tile" - ext_tolerance: 0.01 - grid_system : "BDC-Large V2" - CBERS-MUX-2M : &bdc_cb4_mux - bands : - NDVI : &bdc_mux_ndvi - missing_value : -9999 - minimum_value : -10000 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 20 - band_name : "NDVI" - data_type : "INT2S" - EVI : - <<: *bdc_mux_ndvi - band_name : "EVI" - B05 : &bdc_mux_b5 - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 20 - band_name : "BAND5" - data_type : "INT2S" - B06 : - <<: *bdc_mux_b5 - band_name : "BAND6" - B07 : - <<: *bdc_mux_b5 - band_name : "BAND7" - B08 : - <<: *bdc_mux_b5 - band_name : "BAND8" - CLOUD : &bdc_mux_cloud - bit_mask : false - band_name : "CMASK" - values : - 0 : "No Data" - 127 : "Clear Pixel" - 255 : "Cloud" - interp_values : [0, 255] - resolution : 20 - data_type : "INT1U" - satellite : "CBERS-4" - sensor : "MUX" - collection_name: "CB4MUX_2M-1" - token_vars : ["BDC_ACCESS_KEY"] - open_data : true - open_data_token : true - metadata_search : "tile" - ext_tolerance: 0.01 - grid_system : "BDC-Medium V2" - LANDSAT-OLI-16D : &bdc_lc8 - bands : - NDVI : &bdc_oli_ndvi - missing_value : -9999 - minimum_value : -10000 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 30 - band_name : "NDVI" - data_type : "INT2S" - EVI : - <<: *bdc_oli_ndvi - band_name : "EVI" - COASTAL : &bdc_oli_band1 - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 30 - band_name : "band1" - data_type : "INT2S" - BLUE : - <<: *bdc_oli_band1 - band_name : "band2" - GREEN : - <<: *bdc_oli_band1 - band_name : "band3" - RED : - <<: *bdc_oli_band1 - band_name : "band4" - NIR08 : - <<: *bdc_oli_band1 - band_name : "band5" - SWIR16 : - <<: *bdc_oli_band1 - band_name : "band6" - SWIR22 : - <<: *bdc_oli_band1 - band_name : "band7" - CLOUD : &bdc_oli_cloud - bit_mask : false - band_name : "Fmask4" - values : - 0 : "Clear Land" - 1 : "Clear Water" - 2 : "Cloud Shadow" - 3 : "Snow" - 4 : "Cloud" - 255 : "No Data" - interp_values : [2, 3, 4, 255] - resolution : 30 - data_type : "INT1U" - satellite : "LANDSAT-8" - sensor : "OLI" - collection_name: "LC8_30_16D_STK-1" - token_vars : ["BDC_ACCESS_KEY"] - open_data : true - open_data_token: true - metadata_search : "tile" - ext_tolerance: 0.01 - grid_system : "BDC-Medium V1" - LANDSAT-2M : - bands : - COASTAL : &bdc_lc8_2m_band - missing_value : 0 - minimum_value : 1 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resampling : "bilinear" - resolution : 30 - band_name : "coastal" - data_type : "INT2U" - BLUE : - <<: *bdc_lc8_2m_band - band_name : "blue" - GREEN : - <<: *bdc_lc8_2m_band - band_name : "green" - RED : - <<: *bdc_lc8_2m_band - band_name : "red" - NIR08 : - <<: *bdc_lc8_2m_band - band_name : "nir08" - SWIR16 : - <<: *bdc_lc8_2m_band - band_name : "swir16" - SWIR22 : - <<: *bdc_lc8_2m_band - band_name : "swir22" - NDVI : &bdc_lc8_2m_vi - missing_value : -9999 - minimum_value : -10000 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resampling : "bilinear" - resolution : 30 - band_name : "NDVI" - data_type : "INT2S" - EVI : - <<: *bdc_lc8_2m_vi - band_name : "EVI" - CLOUD : - bit_mask : true - band_name : "qa_pixel" - values : - 0 : "Missing data" - 1 : "Dilated Cloud" - 2 : "High confidence cirrus" - 3 : "High confidence cloud" - 4 : "High confidence cloud shadow" - 5 : "High confidence snow cover" - 6 : "Clear" - 7 : "Water" - 8 : "Low/High confidence of cloud" - 9 : "Medium/High confidence of cloud" - 10 : "Low/High confidence of cloud shadow" - 11 : "Medium/High confidence of cloud shadow" - 12 : "Low/High confidence of snow" - 13 : "Medium/High confidence of snow" - 14 : "Low/High confidence of cirrus" - 15 : "Medium/High confidence of cirrus" - interp_values : [0, 1, 2, 3, 4, 5, 9, 11, 13, 15] - resampling : "near" - resolution : 30 - data_type : "INT2U" - satellite : "LANDSAT" - sensor : "TM-ETM-OLI" - platforms : - LANDSAT-5: "landsat-5" - LANDSAT-7: "landsat-7" - LANDSAT-8: "landsat-8" - LANDSAT-9: "landsat-9" - collection_name: "LANDSAT-2M-1" - token_vars : ["BDC_ACCESS_KEY"] - gdalcubes_support: true - reg_type_format: "INT2S" - open_data : true - open_data_token: true - metadata_search : "feature" - ext_tolerance: 0.01 - grid_system : "BDC-Medium V2" - MOD13Q1-6 : &bdc_mod - bands : - NDVI : &bdc_modis_ndvi - missing_value : -3000 - minimum_value : -2000 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 231.656 - band_name : "NDVI" - data_type : "INT2S" - EVI : - <<: *bdc_modis_ndvi - band_name : "EVI" - BLUE : &bdc_modis_blue - missing_value : -1000 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 231.656 - band_name : "blue_reflectance" - data_type : "INT2S" - RED : - <<: *bdc_modis_blue - band_name : "red_reflectance" - NIR : - <<: *bdc_modis_blue - band_name : "NIR_reflectance" - MIR : - <<: *bdc_modis_blue - band_name : "MIR_reflectance" - CLOUD : &bdc_modis_cloud - bit_mask : false - band_name : "pixel_reliability" - values : - 0 : "Use with confidence" - 1 : "Useful, but look at other QA information" - 2 : "Target covered with snow/ice" - 3 : "Target not visible, covered with cloud" - 255 : "Fill/No Data-Not Processed" - interp_values : [2, 3, 255] - resolution : 231.656 - data_type : "INT1U" - satellite : "TERRA" - sensor : "MODIS" - collection_name: "MOD13Q1-6" - token_vars : ["BDC_ACCESS_KEY"] - open_data : true - open_data_token: true - metadata_search : "tile" - ext_tolerance: 0.01 - grid_system : "STG" - MYD13Q1-6 : - <<: *bdc_mod - satellite : "AQUA" - sensor : "MODIS" - collection_name: "MYD13Q1-6" - open_data : true - open_data_token: true - metadata_search : "tile" - ext_tolerance: 0.01 - grid_system : "STG" - SENTINEL-2-16D : &bdc_s2 - bands : - NDVI : &bdc_msi_ndvi - missing_value : -9999 - minimum_value : -10000 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 10 - band_name : "NDVI" - data_type : "INT2S" - EVI : - <<: *bdc_msi_ndvi - band_name : "EVI" - NBR : - <<: *bdc_msi_ndvi - band_name : "NBR" - B01 : &bdc_msi_band1 - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 10 - band_name : "B01" - data_type : "INT2S" - B02 : - <<: *bdc_msi_band1 - band_name : "B02" - B03 : - <<: *bdc_msi_band1 - band_name : "B03" - B04 : - <<: *bdc_msi_band1 - band_name : "B04" - B05 : - <<: *bdc_msi_band1 - band_name : "B05" - B06 : - <<: *bdc_msi_band1 - band_name : "B06" - B07 : - <<: *bdc_msi_band1 - band_name : "B07" - B08 : - <<: *bdc_msi_band1 - band_name : "B08" - B8A : - <<: *bdc_msi_band1 - band_name : "B8A" - B09 : - <<: *bdc_msi_band1 - band_name : "B09" - B11 : - <<: *bdc_msi_band1 - band_name : "B11" - B12 : - <<: *bdc_msi_band1 - band_name : "B12" - CLOUD : - bit_mask : false - band_name : "SCL" - values : - 0 : "missing_data" - 1 : "defective pixel" - 2 : "shadows" - 3 : "cloud shadows" - 4 : "vegetation" - 5 : "non-vegetated" - 6 : "water" - 7 : "unclassified" - 8 : "cloud medium" - 9 : "cloud high" - 10 : "thin cirrus" - 11 : "snow or ice" - interp_values: [0, 1, 2, 3, 8, 9, 10, 11] - resolution : 10 - data_type : "INT1U" - satellite : "SENTINEL-2" - sensor : "MSI" - collection_name: "S2-16D-2" - token_vars : ["BDC_ACCESS_KEY"] - open_data : true - open_data_token: true - metadata_search : "tile" - ext_tolerance: 0.01 - grid_system : "BDC-Small V2" - AWS : - s3_class : ["aws_cube", "stac_cube", "eo_cube", - "raster_cube"] - service : "STAC" - url : "https://earth-search.aws.element84.com/v1/" - collections : - SENTINEL-2-L2A : - bands : - B01 : &aws_msi_60m - missing_value: -9999 - minimum_value: 0 - maximum_value: 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 60 - band_name : "coastal" - data_type : "INT2S" - B02 : &aws_msi_10m - missing_value: -9999 - minimum_value: 0 - maximum_value: 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 10 - band_name : "blue" - data_type : "INT2S" - B03 : - <<: *aws_msi_10m - band_name : "green" - B04 : - <<: *aws_msi_10m - band_name : "red" - B05 : &aws_msi_20m - missing_value: -9999 - minimum_value: 0 - maximum_value: 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 20 - band_name : "rededge1" - data_type : "INT2S" - B06 : - <<: *aws_msi_20m - band_name : "rededge2" - B07 : - <<: *aws_msi_20m - band_name : "rededge3" - B08 : - <<: *aws_msi_10m - band_name : "nir" - B8A : - <<: *aws_msi_20m - band_name : "nir08" - B09 : - <<: *aws_msi_60m - band_name : "nir09" - B11 : - <<: *aws_msi_20m - band_name : "swir16" - B12 : - <<: *aws_msi_20m - band_name : "swir22" - CLOUD : - bit_mask : false - band_name : "scl" - values : - 0 : "missing_data" - 1 : "defective pixel" - 2 : "shadows" - 3 : "cloud shadows" - 4 : "vegetation" - 5 : "non-vegetated" - 6 : "water" - 7 : "unclassified" - 8 : "cloud medium" - 9 : "cloud high" - 10 : "thin cirrus" - 11 : "snow or ice" - interp_values: [0, 1, 2, 3, 8, 9, 10, 11] - resolution : 20 - data_type : "INT1U" - satellite : "SENTINEL-2" - sensor : "MSI" - platforms : - SENTINEL-2A: "sentinel-2a" - SENTINEL-2B: "sentinel-2b" - collection_name: "sentinel-2-l2a" - access_vars : - AWS_DEFAULT_REGION : "us-west-2" - AWS_S3_ENDPOINT : "s3.amazonaws.com" - AWS_NO_SIGN_REQUEST : true - open_data : true - open_data_token: false - metadata_search : "tile" - ext_tolerance: 0 - grid_system : "MGRS" - SENTINEL-S2-L2A-COGS : - bands : - B01 : &aws_cog_msi_60m - missing_value: -9999 - minimum_value: 0 - maximum_value: 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 60 - band_name : "coastal" - data_type : "INT2S" - B02 : &aws_cog_msi_10m - missing_value: -9999 - minimum_value: 0 - maximum_value: 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 10 - band_name : "blue" - data_type : "INT2S" - B03 : - <<: *aws_cog_msi_10m - band_name : "green" - B04 : - <<: *aws_cog_msi_10m - band_name : "red" - B05 : &aws_cog_msi_20m - missing_value: -9999 - minimum_value: 0 - maximum_value: 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 20 - band_name : "rededge1" - data_type : "INT2S" - B06 : - <<: *aws_cog_msi_20m - band_name : "rededge2" - B07 : - <<: *aws_cog_msi_20m - band_name : "rededge3" - B08 : - <<: *aws_cog_msi_10m - band_name : "nir" - B8A : - <<: *aws_cog_msi_20m - band_name : "nir08" - B09 : - <<: *aws_cog_msi_60m - band_name : "nir09" - B11 : - <<: *aws_cog_msi_20m - band_name : "swir16" - B12 : - <<: *aws_cog_msi_20m - band_name : "swir22" - CLOUD : - bit_mask : false - band_name : "SCL" - values : - 0 : "missing_data" - 1 : "defective pixel" - 2 : "shadows" - 3 : "cloud shadows" - 4 : "vegetation" - 5 : "non-vegetated" - 6 : "water" - 7 : "unclassified" - 8 : "cloud medium" - 9 : "cloud high" - 10 : "thin cirrus" - 11 : "snow or ice" - interp_values: [0, 1, 2, 3, 7, 8, 9, 10, 11] - resolution : 20 - data_type : "INT1U" - satellite : "SENTINEL-2" - sensor : "MSI" - platforms : - SENTINEL-2A: "sentinel-2a" - SENTINEL-2B: "sentinel-2b" - collection_name: "sentinel-2-l2a" - access_vars : - AWS_DEFAULT_REGION : "us-west-1" - AWS_S3_ENDPOINT : "s3.amazonaws.com" - AWS_NO_SIGN_REQUEST : true - open_data: true - open_data_token: false - metadata_search: "tile" - review_dates: ["2020-08-16"] - ext_tolerance: 0 - grid_system : "MGRS" - LANDSAT-C2-L2 : &aws_oli - bands : - BLUE : &aws_oli_30m - missing_value : 0 - minimum_value : 7273 - maximum_value : 43636 - scale_factor : 0.0000275 - offset_value : -0.2 - resampling : "bilinear" - resolution : 30 - band_name : "blue" - data_type : "INT2U" - GREEN : - <<: *aws_oli_30m - band_name : "green" - RED : - <<: *aws_oli_30m - band_name : "red" - NIR08 : - <<: *aws_oli_30m - band_name : "nir08" - SWIR16 : - <<: *aws_oli_30m - band_name : "swir16" - SWIR22 : - <<: *aws_oli_30m - band_name : "swir22" - CLOUD : - bit_mask : true - band_name : "qa_pixel" - values : - 0 : "Missing data" - 1 : "Dilated Cloud" - 2 : "High confidence cirrus" - 3 : "High confidence cloud" - 4 : "High confidence cloud shadow" - 5 : "High confidence snow cover" - 6 : "Clear" - 7 : "Water" - 8 : "Low/High confidence of cloud" - 9 : "Medium/High confidence of cloud" - 10 : "Low/High confidence of cloud shadow" - 11 : "Medium/High confidence of cloud shadow" - 12 : "Low/High confidence of snow" - 13 : "Medium/High confidence of snow" - 14 : "Low/High confidence of cirrus" - 15 : "Medium/High confidence of cirrus" - interp_values : [0, 1, 2, 3, 4, 5, 9, 11, 13, 15] - resampling : "near" - resolution : 30 - data_type : "INT2U" - satellite : "LANDSAT" - sensor : "TM-ETM-OLI" - platforms : - LANDSAT-5: "landsat-5" - LANDSAT-7: "landsat-7" - LANDSAT-8: "landsat-8" - LANDSAT-9: "landsat-9" - collection_name: "landsat-c2-l2" - access_vars : - AWS_DEFAULT_REGION : "us-west-2" - AWS_S3_ENDPOINT : "s3.amazonaws.com" - AWS_REQUEST_PAYER : "requester" - AWS_NO_SIGN_REQUEST : false - open_data : false - open_data_token: false - metadata_search : "feature" - ext_tolerance: 0 - grid_system : "WRS-2" - DEAFRICA : - s3_class : ["deafrica_cube", "stac_cube", "eo_cube", - "raster_cube"] - service : "STAC" - url : "https://explorer.digitalearth.africa/stac/" - collections : - S2_L2A : - bands : - B01 : &deafrica_msi_60m - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 60 - band_name : "B01" - data_type : "INT2S" - B02 : &deafrica_msi_10m - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 10 - band_name : "B02" - data_type : "INT2S" - B03 : - <<: *deafrica_msi_10m - band_name : "B03" - B04 : - <<: *deafrica_msi_10m - band_name : "B04" - B05 : &deafrica_msi_20m - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 20 - band_name : "B05" - data_type : "INT2S" - B06 : - <<: *deafrica_msi_20m - band_name : "B06" - B07 : - <<: *deafrica_msi_20m - band_name : "B07" - B08 : - <<: *deafrica_msi_10m - band_name : "B08" - B8A : - <<: *deafrica_msi_20m - band_name : "B8A" - B09 : - <<: *deafrica_msi_60m - band_name : "B09" - B11 : - <<: *deafrica_msi_20m - band_name : "B11" - B12 : - <<: *deafrica_msi_20m - band_name : "B12" - CLOUD : - bit_mask : false - band_name : "SCL" - values : - 0 : "missing_data" - 1 : "defective pixel" - 2 : "shadows" - 3 : "cloud shadows" - 4 : "vegetation" - 5 : "non-vegetated" - 6 : "water" - 7 : "unclassified" - 8 : "cloud medium" - 9 : "cloud high" - 10 : "thin cirrus" - 11 : "snow or ice" - interp_values : [0, 1, 2, 3, 8, 9, 10, 11] - resolution : 20 - data_type : "INT1U" - satellite : "SENTINEL-2" - sensor : "MSI" - collection_name: "s2_l2a" - access_vars : - AWS_DEFAULT_REGION: "af-south-1" - AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" - AWS_NO_SIGN_REQUEST: true - open_data: true - open_data_token: false - metadata_search : "tile" - ext_tolerance: 0 - grid_system : "MGRS" - LS8_SR : &deafrica_l8 - bands : - B01 : &deafrica_oli_30m - missing_value : 0 - minimum_value : 7273 - maximum_value : 43636 - scale_factor : 0.0000275 - offset_value : -0.2 - resampling : "bilinear" - resolution : 30 - band_name : "SR_B1" - data_type : "INT2U" - B02 : - <<: *deafrica_oli_30m - band_name : "SR_B2" - B03 : - <<: *deafrica_oli_30m - band_name : "SR_B3" - B04 : - <<: *deafrica_oli_30m - band_name : "SR_B4" - B05 : - <<: *deafrica_oli_30m - band_name : "SR_B5" - B06 : - <<: *deafrica_oli_30m - band_name : "SR_B6" - B07 : - <<: *deafrica_oli_30m - band_name : "SR_B7" - CLOUD : - bit_mask : true - band_name : "QA_PIXEL" - values : - 0 : "missing_data" - 1 : "Dilated Cloud" - 2 : "High confidence cirrus" - 4 : "High confidence cloud shadow" - 5 : "High confidence snow cover" - 6 : "Clear" - 7 : "Water" - 9 : "High confidence of cloud" - 11 : "High confidence of cloud shadow" - 13 : "High confidence of snow" - 15 : "High confidence of cirrus" - interp_values : [0, 1, 2, 3, 4, 5] - resampling : "near" - resolution : 30 - data_type : "INT2U" - satellite : "LANDSAT-8" - sensor : "OLI" - collection_name: "ls8_sr" - access_vars : - AWS_DEFAULT_REGION: "af-south-1" - AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" - AWS_NO_SIGN_REQUEST: true - open_data: true - open_data_token: false - metadata_search : "feature" - ext_tolerance: 0 - grid_system : "WRS-2" - SDC : - s3_class : ["sdc_cube", "stac_cube", "eo_cube", - "raster_cube"] - service : "STAC" - url : "https://explorer.swissdatacube.org/stac" - collections : - S2_L2A_10M_SWISS: &swiss_s2 - bands : - B01 : &swiss_msi_10m - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 10 - band_name : "coastal_aerosol" - data_type : "INT2S" - B02 : - <<: *swiss_msi_10m - band_name : "blue" - B03 : - <<: *swiss_msi_10m - band_name : "green" - B04 : - <<: *swiss_msi_10m - band_name : "red" - B05 : - <<: *swiss_msi_10m - band_name : "veg5" - B06 : - <<: *swiss_msi_10m - band_name : "veg6" - B07 : - <<: *swiss_msi_10m - band_name : "veg7" - B08 : - <<: *swiss_msi_10m - band_name : "nir" - B8A : - <<: *swiss_msi_10m - band_name : "narrow_nir" - B09 : - <<: *swiss_msi_10m - band_name : "water_vapour" - B11 : - <<: *swiss_msi_10m - band_name : "swir1" - B12 : - <<: *swiss_msi_10m - band_name : "swir2" - CLOUD : - bit_mask : false - band_name : "scl" - values : - 0 : "missing_data" - 1 : "defective pixel" - 2 : "shadows" - 3 : "cloud shadows" - 4 : "vegetation" - 5 : "non-vegetated" - 6 : "water" - 7 : "unclassified" - 8 : "cloud medium" - 9 : "cloud high" - 10 : "thin cirrus" - 11 : "snow or ice" - interp_values : [0, 1, 2, 3, 8, 9, 10, 11] - resolution : 20 - data_type : "INT1U" - satellite : "SENTINEL-2" - sensor : "MSI" - collection_name: "s2_l2a_10m_swiss" - open_data: true - open_data_token: false - metadata_search : "feature" - ext_tolerance: 0 - grid_system : "MGRS" - LS8_LASRC_SWISS : &swiss_l8 - bands : - B01 : &swiss_oli_30m - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resampling : "bilinear" - resolution : 30 - band_name : "coastal_aerosol" - data_type : "INT2S" - B02 : - <<: *swiss_oli_30m - band_name : "blue" - B03 : - <<: *swiss_oli_30m - band_name : "green" - B04 : - <<: *swiss_oli_30m - band_name : "red" - B05 : - <<: *swiss_oli_30m - band_name : "nir" - B06 : - <<: *swiss_oli_30m - band_name : "swir1" - B07 : - <<: *swiss_oli_30m - band_name : "swir2" - CLOUD : - bit_mask : true - band_name : "pixel_qa" - values : - 0 : "missing_data" - 1 : "Clear" - 2 : "Water" - 3 : "Cloud Shadow" - 4 : "Snow" - 5 : "Cloud" - 6 : "Low/High confidence of cloud" - 7 : "Medium/High confidence of cloud" - 8 : "Low/High confidence of cirrus" - 9 : "Medium/High confidence of cirrus" - 10 : "Terrain Occlusion" - 11 : "Unused" - 12 : "Unused" - 13 : "Unused" - 14 : "Unused" - 15 : "Unused" - interp_values : [0, 3, 4, 5, 7, 9, 10] - resampling : "near" - resolution : 30 - data_type : "INT2U" - satellite : "LANDSAT-8" - sensor : "OLI" - collection_name: "ls8_lasrc_swiss" - open_data: true - open_data_token: false - metadata_search : "feature" - ext_tolerance: 0 - grid_system : "WRS-2" - USGS : - s3_class : ["usgs_cube", "stac_cube", "eo_cube", - "raster_cube"] - service : "STAC" - rstac_version : "0.9.0" - url : "https://landsatlook.usgs.gov/stac-server" - collections : - LANDSAT-C2L2-SR : &usgs_oli - bands : - BLUE : &usgs_oli_30m - missing_value : 0 - minimum_value : 7273 - maximum_value : 43636 - scale_factor : 0.0000275 - offset_value : -0.2 - resampling : "bilinear" - resolution : 30 - band_name : "blue" - data_type : "INT2U" - GREEN : - <<: *usgs_oli_30m - band_name : "green" - RED : - <<: *usgs_oli_30m - band_name : "red" - NIR08 : - <<: *usgs_oli_30m - band_name : "nir08" - SWIR16 : - <<: *usgs_oli_30m - band_name : "swir16" - SWIR22 : - <<: *usgs_oli_30m - band_name : "swir22" - CLOUD : - bit_mask : true - band_name : "qa_pixel" - values : - 0 : "Missing data" - 1 : "Dilated Cloud" - 2 : "High confidence cirrus" - 3 : "High confidence cloud" - 4 : "High confidence cloud shadow" - 5 : "High confidence snow cover" - 6 : "Clear" - 7 : "Water" - 8 : "Low/High confidence of cloud" - 9 : "Medium/High confidence of cloud" - 10 : "Low/High confidence of cloud shadow" - 11 : "Medium/High confidence of cloud shadow" - 12 : "Low/High confidence of snow" - 13 : "Medium/High confidence of snow" - 14 : "Low/High confidence of cirrus" - 15 : "Medium/High confidence of cirrus" - interp_values : [0, 1, 2, 3, 4, 5, 9, 11, 13, 15] - resampling : "near" - resolution : 30 - data_type : "INT2U" - satellite : "LANDSAT" - sensor : "TM/ETM+/OLI" - platforms : - LANDSAT-5: "LANDSAT_5" - LANDSAT-7: "LANDSAT_7" - LANDSAT-8: "LANDSAT_8" - LANDSAT-9: "LANDSAT_9" - collection_name: "landsat-c2l2-sr" - access_vars : - AWS_DEFAULT_REGION: "us-west-2" - AWS_S3_ENDPOINT : "s3.amazonaws.com" - AWS_REQUEST_PAYER : "requester" - AWS_NO_SIGN_REQUEST : false - open_data: false - open_data_token: false - tile_required: false - metadata_search : "feature" - ext_tolerance: 0 - grid_system : "WRS-2" - MPC : - s3_class : ["mpc_cube", "stac_cube", "eo_cube", - "raster_cube"] - service : "STAC" - rstac_version : "1.0.0" - url : "https://planetarycomputer.microsoft.com/api/stac/v1" - token_url : "https://planetarycomputer.microsoft.com/api/sas/v1/token" - collections : - LANDSAT-C2-L2 : &mspc_oli - bands : - BLUE : &mspc_oli_30m - missing_value : 0 - minimum_value : 7273 - maximum_value : 43636 - scale_factor : 0.0000275 - offset_value : -0.2 - resampling : "bilinear" - resolution : 30 - band_name : "blue" - data_type : "INT2U" - GREEN : - <<: *mspc_oli_30m - band_name : "green" - RED : - <<: *mspc_oli_30m - band_name : "red" - NIR08 : - <<: *mspc_oli_30m - band_name : "nir08" - SWIR16 : - <<: *mspc_oli_30m - band_name : "swir16" - SWIR22 : - <<: *mspc_oli_30m - band_name : "swir22" - CLOUD : - bit_mask : true - band_name : "qa_pixel" - values : - 0 : "Missing data" - 1 : "Dilated Cloud" - 2 : "High confidence cirrus" - 3 : "High confidence cloud" - 4 : "High confidence cloud shadow" - 5 : "High confidence snow cover" - 6 : "Clear" - 7 : "Water" - 8 : "Low/High confidence of cloud" - 9 : "Medium/High confidence of cloud" - 10 : "Low/High confidence of cloud shadow" - 11 : "Medium/High confidence of cloud shadow" - 12 : "Low/High confidence of snow" - 13 : "Medium/High confidence of snow" - 14 : "Low/High confidence of cirrus" - 15 : "Medium/High confidence of cirrus" - interp_values : [0, 1, 2, 3, 4, 5, 9, 11, 13, 15] - resampling : "near" - resolution : 30 - data_type : "INT2U" - satellite : "LANDSAT" - sensor : "TM-ETM-OLI" - platforms : - LANDSAT-5: "landsat-5" - LANDSAT-7: "landsat-7" - LANDSAT-8: "landsat-8" - LANDSAT-9: "landsat-9" - collection_name: "landsat-c2-l2" - open_data: true - open_data_token: false - tile_required: false - metadata_search : "feature" - ext_tolerance: 0 - grid_system : "WRS-2" - SENTINEL-2-L2A : &mspc_msi - bands : - B01 : &mspc_msi_60m - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 60 - band_name : "B01" - data_type : "INT2S" - B02 : &mspc_msi_10m - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 10 - band_name : "B02" - data_type : "INT2S" - B03 : - <<: *mspc_msi_10m - band_name : "B03" - B04 : - <<: *mspc_msi_10m - band_name : "B04" - B05 : &mspc_msi_20m - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 20 - band_name : "B05" - data_type : "INT2S" - B06 : - <<: *mspc_msi_20m - band_name : "B06" - B07 : - <<: *mspc_msi_20m - band_name : "B07" - B08 : - <<: *mspc_msi_10m - band_name : "B08" - B8A : - <<: *mspc_msi_20m - band_name : "B8A" - B09 : - <<: *mspc_msi_60m - band_name : "B09" - B11 : - <<: *mspc_msi_20m - band_name : "B11" - B12 : - <<: *mspc_msi_20m - band_name : "B12" - CLOUD : - bit_mask : false - band_name : "SCL" - values : - 0 : "missing_data" - 1 : "defective pixel" - 2 : "shadows" - 3 : "cloud shadows" - 4 : "vegetation" - 5 : "non-vegetated" - 6 : "water" - 7 : "unclassified" - 8 : "cloud medium" - 9 : "cloud high" - 10 : "thin cirrus" - 11 : "snow or ice" - interp_values : [0, 1, 2, 3, 8, 9, 10, 11] - resolution : 20 - data_type : "INT1U" - satellite : "SENTINEL-2" - sensor : "MSI" - platforms : - SENTINEL-2A: "Sentinel-2A" - SENTINEL-2B: "Sentinel-2B" - collection_name: "sentinel-2-l2a" - open_data: true - open_data_token: false - metadata_search : "tile" - ext_tolerance: 0 - grid_system : "MGRS" - SENTINEL-1-GRD : &mspc_s1_grd - bands : - VV : &mspc_grd_10m - missing_value : 0 - minimum_value : 1 - maximum_value : 65534 - scale_factor : 0.001 - offset_value : 0 - resolution : 10 - band_name : "vv" - data_type : "INT2U" - VH : - <<: *mspc_grd_10m - band_name : "vh" - satellite : "SENTINEL-1" - sensor : "C-band-SAR" - orbits : ["ascending", "descending"] - platforms : - SENTINEL-1A: "Sentinel-1A" - SENTINEL-1B: "Sentinel-1B" - collection_name: "sentinel-1-grd" - sar_cube: true - open_data: true - open_data_token: false - metadata_search: "feature" - ext_tolerance: 0 - grid_system : "MGRS" - SENTINEL-1-RTC : &mspc_s1_rtc - bands : - VV : &mspc_rtc_10m - missing_value : -32768.0 - minimum_value : 0 - maximum_value : 65534 - scale_factor : 1 - offset_value : 0 - resolution : 10 - band_name : "vv" - data_type : "FLT4S" - VH : - <<: *mspc_rtc_10m - band_name : "vh" - satellite : "SENTINEL-1" - sensor : "C-band-SAR" - orbits : ["ascending", "descending"] - platforms : - SENTINEL-1A: "Sentinel-1A" - SENTINEL-1B: "Sentinel-1B" - collection_name: "sentinel-1-rtc" - sar_cube: true - open_data: false - open_data_token: false - metadata_search: "feature" - ext_tolerance: 0 - grid_system : "MGRS" - token_vars : ["MPC_TOKEN"] - HLS : - s3_class : ["hls_cube", "stac_cube", "eo_cube", - "raster_cube"] - service : "STAC" - rstac_version : "1.0.0" - url : "https://cmr.earthdata.nasa.gov/stac/LPCLOUD" - collections : - HLSS30 : - bands : - COASTAL-AEROSOL: &hls_s2_30m - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 30 - band_name : "B01" - data_type : "INT2S" - BLUE : - <<: *hls_s2_30m - band_name : "B02" - GREEN : - <<: *hls_s2_30m - band_name : "B03" - RED : - <<: *hls_s2_30m - band_name : "B04" - RED-EDGE-1: - <<: *hls_s2_30m - band_name : "B05" - RED-EDGE-2: - <<: *hls_s2_30m - band_name : "B06" - RED-EDGE-3: - <<: *hls_s2_30m - band_name : "B07" - NIR-BROAD: - <<: *hls_s2_30m - band_name : "B08" - NIR-NARROW: - <<: *hls_s2_30m - band_name : "B8A" - WATER-VAPOR: - <<: *hls_s2_30m - band_name : "B09" - SWIR-1 : - <<: *hls_s2_30m - band_name : "B11" - SWIR-2 : - <<: *hls_s2_30m - band_name : "B12" - CLOUD : - bit_mask : true - band_name : "Fmask" - values : - 0 : "Cirrus" - 1 : "Cloud" - 2 : "Adjacent to cloud/shadow" - 3 : "Cloud shadow" - 4 : "Snow/ice" - 5 : "Water" - 6 : "Aerosol level (low)" - 7 : "Aerosol level (moderate or high)" - interp_values : [1, 2, 3, 4, 7] - resampling : "near" - resolution : 30 - data_type : "INT1U" - satellite : "SENTINEL-2" - sensor : "MSI" - collection_name: "HLSS30.v2.0" - access_vars : - GDAL_HTTP_UNSAFESSL: "YES" - GDAL_HTTP_COOKIEFILE: ".rcookies" - GDAL_HTTP_COOKIEJAR: ".rcookies" - open_data: true - open_data_token: false - metadata_search : "tile" - ext_tolerance: 0 - grid_system : "MGRS" - HLSL30 : - bands : - COASTAL-AEROSOL: &hls_l8_30m - missing_value : -9999 - minimum_value : 0 - maximum_value : 10000 - scale_factor : 0.0001 - offset_value : 0 - resolution : 30 - band_name : "B01" - data_type : "INT2S" - BLUE : - <<: *hls_l8_30m - band_name : "B02" - GREEN : - <<: *hls_l8_30m - band_name : "B03" - RED : - <<: *hls_l8_30m - band_name : "B04" - NIR-NARROW: - <<: *hls_l8_30m - band_name : "B05" - SWIR-1 : - <<: *hls_l8_30m - band_name : "B06" - SWIR-2 : - <<: *hls_l8_30m - band_name : "B07" - CLOUD : - bit_mask : true - band_name : "Fmask" - values : - 0 : "Cirrus" - 1 : "Cloud" - 2 : "Adjacent to cloud/shadow" - 3 : "Cloud shadow" - 4 : "Snow/ice" - 5 : "Water" - 6 : "Aerosol level (low)" - 7 : "Aerosol level (moderate or high)" - interp_values : [1, 2, 3, 4, 7] - resampling : "near" - resolution : 30 - data_type : "INT1U" - satellite : "LANDSAT-8" - sensor : "OLI" - collection_name: "hlsl30.v2.0" - access_vars : - GDAL_HTTP_UNSAFESSL: "YES" - GDAL_HTTP_COOKIEFILE: ".rcookies" - GDAL_HTTP_COOKIEJAR: ".rcookies" - open_data: true - open_data_token: false - metadata_search : "tile" - ext_tolerance: 0 - grid_system : "MGRS" diff --git a/inst/extdata/config_messages.yml b/inst/extdata/config_messages.yml index b4ca8bb52..fa4185352 100644 --- a/inst/extdata/config_messages.yml +++ b/inst/extdata/config_messages.yml @@ -103,6 +103,7 @@ .conf_add_color_table: "invalid color table - missing either name or hex columns" .conf_internals_file: "unable to find config_internals file" .conf_messages_file: "unable to find config_messages file" +.conf_sources_files: "unable to find config_sources files" .conf_file: "invalid configuration file" .conf_merge_legends: "user defined legends already exist in sits - see sits_colors_show()" .conf_merge_legends_user: "invalid user legends" @@ -198,6 +199,7 @@ .source_collection_token_check: "missing access token for collection" .source_items_new: "search returned no items - check selection parameters." .source_items_new_hls_cube: "could not find .netrc file\n please configure your access to NASA EarthData" +.source_items_new_cdse_cube: "search returned no items - check selection parameters." .source_items_new_mpc_cube_landsat_c2_l2: "when retrieving Landsat collection in MPC searching by tiles is not allowed, use roi" .source_items_bands_select: "unable to retrieve selected bands from chosen collection - check input parameters" .source_items_cube: "error when retrieving items using stac query - check selection parameters" diff --git a/inst/extdata/config_source_aws.yml b/inst/extdata/config_source_aws.yml new file mode 100644 index 000000000..ba1d9c66e --- /dev/null +++ b/inst/extdata/config_source_aws.yml @@ -0,0 +1,260 @@ +# These are configuration parameters that can be set by users +# The parameters enable access to the cloud collections + +sources: + AWS : + s3_class : ["aws_cube", "stac_cube", "eo_cube", + "raster_cube"] + service : "STAC" + url : "https://earth-search.aws.element84.com/v1/" + collections : + SENTINEL-2-L2A : + bands : + B01 : &aws_msi_60m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 60 + band_name : "coastal" + data_type : "INT2S" + B02 : &aws_msi_10m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 10 + band_name : "blue" + data_type : "INT2S" + B03 : + <<: *aws_msi_10m + band_name : "green" + B04 : + <<: *aws_msi_10m + band_name : "red" + B05 : &aws_msi_20m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 20 + band_name : "rededge1" + data_type : "INT2S" + B06 : + <<: *aws_msi_20m + band_name : "rededge2" + B07 : + <<: *aws_msi_20m + band_name : "rededge3" + B08 : + <<: *aws_msi_10m + band_name : "nir" + B8A : + <<: *aws_msi_20m + band_name : "nir08" + B09 : + <<: *aws_msi_60m + band_name : "nir09" + B11 : + <<: *aws_msi_20m + band_name : "swir16" + B12 : + <<: *aws_msi_20m + band_name : "swir22" + CLOUD : + bit_mask : false + band_name : "scl" + values : + 0 : "missing_data" + 1 : "defective pixel" + 2 : "shadows" + 3 : "cloud shadows" + 4 : "vegetation" + 5 : "non-vegetated" + 6 : "water" + 7 : "unclassified" + 8 : "cloud medium" + 9 : "cloud high" + 10 : "thin cirrus" + 11 : "snow or ice" + interp_values: [0, 1, 2, 3, 8, 9, 10, 11] + resolution : 20 + data_type : "INT1U" + satellite : "SENTINEL-2" + sensor : "MSI" + platforms : + SENTINEL-2A: "sentinel-2a" + SENTINEL-2B: "sentinel-2b" + collection_name: "sentinel-2-l2a" + access_vars : + AWS_DEFAULT_REGION : "us-west-2" + AWS_S3_ENDPOINT : "s3.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data : true + open_data_token: false + metadata_search : "tile" + ext_tolerance: 0 + grid_system : "MGRS" + SENTINEL-S2-L2A-COGS : + bands : + B01 : &aws_cog_msi_60m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 60 + band_name : "coastal" + data_type : "INT2S" + B02 : &aws_cog_msi_10m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 10 + band_name : "blue" + data_type : "INT2S" + B03 : + <<: *aws_cog_msi_10m + band_name : "green" + B04 : + <<: *aws_cog_msi_10m + band_name : "red" + B05 : &aws_cog_msi_20m + missing_value: -9999 + minimum_value: 0 + maximum_value: 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 20 + band_name : "rededge1" + data_type : "INT2S" + B06 : + <<: *aws_cog_msi_20m + band_name : "rededge2" + B07 : + <<: *aws_cog_msi_20m + band_name : "rededge3" + B08 : + <<: *aws_cog_msi_10m + band_name : "nir" + B8A : + <<: *aws_cog_msi_20m + band_name : "nir08" + B09 : + <<: *aws_cog_msi_60m + band_name : "nir09" + B11 : + <<: *aws_cog_msi_20m + band_name : "swir16" + B12 : + <<: *aws_cog_msi_20m + band_name : "swir22" + CLOUD : + bit_mask : false + band_name : "SCL" + values : + 0 : "missing_data" + 1 : "defective pixel" + 2 : "shadows" + 3 : "cloud shadows" + 4 : "vegetation" + 5 : "non-vegetated" + 6 : "water" + 7 : "unclassified" + 8 : "cloud medium" + 9 : "cloud high" + 10 : "thin cirrus" + 11 : "snow or ice" + interp_values: [0, 1, 2, 3, 7, 8, 9, 10, 11] + resolution : 20 + data_type : "INT1U" + satellite : "SENTINEL-2" + sensor : "MSI" + platforms : + SENTINEL-2A: "sentinel-2a" + SENTINEL-2B: "sentinel-2b" + collection_name: "sentinel-2-l2a" + access_vars : + AWS_DEFAULT_REGION : "us-west-1" + AWS_S3_ENDPOINT : "s3.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data: true + open_data_token: false + metadata_search: "tile" + review_dates: ["2020-08-16"] + ext_tolerance: 0 + grid_system : "MGRS" + LANDSAT-C2-L2 : &aws_oli + bands : + BLUE : &aws_oli_30m + missing_value : 0 + minimum_value : 7273 + maximum_value : 43636 + scale_factor : 0.0000275 + offset_value : -0.2 + resampling : "bilinear" + resolution : 30 + band_name : "blue" + data_type : "INT2U" + GREEN : + <<: *aws_oli_30m + band_name : "green" + RED : + <<: *aws_oli_30m + band_name : "red" + NIR08 : + <<: *aws_oli_30m + band_name : "nir08" + SWIR16 : + <<: *aws_oli_30m + band_name : "swir16" + SWIR22 : + <<: *aws_oli_30m + band_name : "swir22" + CLOUD : + bit_mask : true + band_name : "qa_pixel" + values : + 0 : "Missing data" + 1 : "Dilated Cloud" + 2 : "High confidence cirrus" + 3 : "High confidence cloud" + 4 : "High confidence cloud shadow" + 5 : "High confidence snow cover" + 6 : "Clear" + 7 : "Water" + 8 : "Low/High confidence of cloud" + 9 : "Medium/High confidence of cloud" + 10 : "Low/High confidence of cloud shadow" + 11 : "Medium/High confidence of cloud shadow" + 12 : "Low/High confidence of snow" + 13 : "Medium/High confidence of snow" + 14 : "Low/High confidence of cirrus" + 15 : "Medium/High confidence of cirrus" + interp_values : [0, 1, 2, 3, 4, 5, 9, 11, 13, 15] + resampling : "near" + resolution : 30 + data_type : "INT2U" + satellite : "LANDSAT" + sensor : "TM-ETM-OLI" + platforms : + LANDSAT-5: "landsat-5" + LANDSAT-7: "landsat-7" + LANDSAT-8: "landsat-8" + LANDSAT-9: "landsat-9" + collection_name: "landsat-c2-l2" + access_vars : + AWS_DEFAULT_REGION : "us-west-2" + AWS_S3_ENDPOINT : "s3.amazonaws.com" + AWS_REQUEST_PAYER : "requester" + AWS_NO_SIGN_REQUEST : false + open_data : false + open_data_token: false + metadata_search : "feature" + ext_tolerance: 0 + grid_system : "WRS-2" diff --git a/inst/extdata/config_source_bdc.yml b/inst/extdata/config_source_bdc.yml new file mode 100644 index 000000000..396f48c93 --- /dev/null +++ b/inst/extdata/config_source_bdc.yml @@ -0,0 +1,450 @@ +# These are configuration parameters that can be set by users +# The parameters enable access to the cloud collections + +# BDC access key +BDC_ACCESS_KEY: "vtclkRc5c874XBd0Y7NSUWuzLihnU1bHC5bbLSXfQ5" + +sources: + BDC : + s3_class : ["bdc_cube", "stac_cube", "eo_cube", + "raster_cube"] + service : "STAC" + url : "https://brazildatacube.dpi.inpe.br/stac/" + collections : + CBERS-WFI-16D : &bdc_cb4_awfi + bands : + NDVI : &bdc_awfi_ndvi + missing_value : -9999 + minimum_value : -10000 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 64 + band_name : "NDVI" + data_type : "INT2S" + EVI : + <<: *bdc_awfi_ndvi + band_name : "EVI" + B13 : &bdc_awfi_b13 + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 64 + band_name : "BAND13" + data_type : "INT2S" + B14 : + <<: *bdc_awfi_b13 + band_name : "BAND14" + B15 : + <<: *bdc_awfi_b13 + band_name : "BAND15" + B16 : + <<: *bdc_awfi_b13 + band_name : "BAND16" + CLOUD : &bdc_awfi_cloud + bit_mask : false + band_name : "CMASK" + values : + 0 : "No Data" + 127 : "Clear Pixel" + 255 : "Cloud" + interp_values : [0, 255] + resolution : 64 + data_type : "INT1U" + satellite : "CBERS-4" + sensor : "WFI" + collection_name: "CB4-16D-2" + token_vars : ["BDC_ACCESS_KEY"] + open_data : true + open_data_token : true + metadata_search : "tile" + ext_tolerance: 0.01 + grid_system : "BDC-Large V2" + CBERS-WFI-8D : + bands : + NDVI : + <<: *bdc_awfi_ndvi + band_name : "NDVI" + EVI : + <<: *bdc_awfi_ndvi + band_name : "EVI" + B13 : + <<: *bdc_awfi_b13 + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 64 + band_name : "BAND13" + data_type : "INT2S" + B14 : + <<: *bdc_awfi_b13 + band_name : "BAND14" + B15 : + <<: *bdc_awfi_b13 + band_name : "BAND15" + B16 : + <<: *bdc_awfi_b13 + band_name : "BAND16" + CLOUD : + <<: *bdc_awfi_cloud + band_name : "CMASK" + satellite : "CBERS-4-4A" + sensor : "WFI" + collection_name: "CBERS-WFI_64_8D_LCF-1" + token_vars : ["BDC_ACCESS_KEY"] + open_data : true + open_data_token : true + metadata_search : "tile" + ext_tolerance: 0.01 + grid_system : "BDC-Large V2" + CBERS-MUX-2M : &bdc_cb4_mux + bands : + NDVI : &bdc_mux_ndvi + missing_value : -9999 + minimum_value : -10000 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 20 + band_name : "NDVI" + data_type : "INT2S" + EVI : + <<: *bdc_mux_ndvi + band_name : "EVI" + B05 : &bdc_mux_b5 + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 20 + band_name : "BAND5" + data_type : "INT2S" + B06 : + <<: *bdc_mux_b5 + band_name : "BAND6" + B07 : + <<: *bdc_mux_b5 + band_name : "BAND7" + B08 : + <<: *bdc_mux_b5 + band_name : "BAND8" + CLOUD : &bdc_mux_cloud + bit_mask : false + band_name : "CMASK" + values : + 0 : "No Data" + 127 : "Clear Pixel" + 255 : "Cloud" + interp_values : [0, 255] + resolution : 20 + data_type : "INT1U" + satellite : "CBERS-4" + sensor : "MUX" + collection_name: "CB4MUX_2M-1" + token_vars : ["BDC_ACCESS_KEY"] + open_data : true + open_data_token : true + metadata_search : "tile" + ext_tolerance: 0.01 + grid_system : "BDC-Medium V2" + LANDSAT-OLI-16D : &bdc_lc8 + bands : + NDVI : &bdc_oli_ndvi + missing_value : -9999 + minimum_value : -10000 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 30 + band_name : "NDVI" + data_type : "INT2S" + EVI : + <<: *bdc_oli_ndvi + band_name : "EVI" + COASTAL : &bdc_oli_band1 + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 30 + band_name : "band1" + data_type : "INT2S" + BLUE : + <<: *bdc_oli_band1 + band_name : "band2" + GREEN : + <<: *bdc_oli_band1 + band_name : "band3" + RED : + <<: *bdc_oli_band1 + band_name : "band4" + NIR08 : + <<: *bdc_oli_band1 + band_name : "band5" + SWIR16 : + <<: *bdc_oli_band1 + band_name : "band6" + SWIR22 : + <<: *bdc_oli_band1 + band_name : "band7" + CLOUD : &bdc_oli_cloud + bit_mask : false + band_name : "Fmask4" + values : + 0 : "Clear Land" + 1 : "Clear Water" + 2 : "Cloud Shadow" + 3 : "Snow" + 4 : "Cloud" + 255 : "No Data" + interp_values : [2, 3, 4, 255] + resolution : 30 + data_type : "INT1U" + satellite : "LANDSAT-8" + sensor : "OLI" + collection_name: "LC8_30_16D_STK-1" + token_vars : ["BDC_ACCESS_KEY"] + open_data : true + open_data_token: true + metadata_search : "tile" + ext_tolerance: 0.01 + grid_system : "BDC-Medium V1" + LANDSAT-2M : + bands : + COASTAL : &bdc_lc8_2m_band + missing_value : 0 + minimum_value : 1 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "coastal" + data_type : "INT2U" + BLUE : + <<: *bdc_lc8_2m_band + band_name : "blue" + GREEN : + <<: *bdc_lc8_2m_band + band_name : "green" + RED : + <<: *bdc_lc8_2m_band + band_name : "red" + NIR08 : + <<: *bdc_lc8_2m_band + band_name : "nir08" + SWIR16 : + <<: *bdc_lc8_2m_band + band_name : "swir16" + SWIR22 : + <<: *bdc_lc8_2m_band + band_name : "swir22" + NDVI : &bdc_lc8_2m_vi + missing_value : -9999 + minimum_value : -10000 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "NDVI" + data_type : "INT2S" + EVI : + <<: *bdc_lc8_2m_vi + band_name : "EVI" + CLOUD : + bit_mask : true + band_name : "qa_pixel" + values : + 0 : "Missing data" + 1 : "Dilated Cloud" + 2 : "High confidence cirrus" + 3 : "High confidence cloud" + 4 : "High confidence cloud shadow" + 5 : "High confidence snow cover" + 6 : "Clear" + 7 : "Water" + 8 : "Low/High confidence of cloud" + 9 : "Medium/High confidence of cloud" + 10 : "Low/High confidence of cloud shadow" + 11 : "Medium/High confidence of cloud shadow" + 12 : "Low/High confidence of snow" + 13 : "Medium/High confidence of snow" + 14 : "Low/High confidence of cirrus" + 15 : "Medium/High confidence of cirrus" + interp_values : [0, 1, 2, 3, 4, 5, 9, 11, 13, 15] + resampling : "near" + resolution : 30 + data_type : "INT2U" + satellite : "LANDSAT" + sensor : "TM-ETM-OLI" + platforms : + LANDSAT-5: "landsat-5" + LANDSAT-7: "landsat-7" + LANDSAT-8: "landsat-8" + LANDSAT-9: "landsat-9" + collection_name: "LANDSAT-2M-1" + token_vars : ["BDC_ACCESS_KEY"] + gdalcubes_support: true + reg_type_format: "INT2S" + open_data : true + open_data_token: true + metadata_search : "feature" + ext_tolerance: 0.01 + grid_system : "BDC-Medium V2" + MOD13Q1-6 : &bdc_mod + bands : + NDVI : &bdc_modis_ndvi + missing_value : -3000 + minimum_value : -2000 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 231.656 + band_name : "NDVI" + data_type : "INT2S" + EVI : + <<: *bdc_modis_ndvi + band_name : "EVI" + BLUE : &bdc_modis_blue + missing_value : -1000 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 231.656 + band_name : "blue_reflectance" + data_type : "INT2S" + RED : + <<: *bdc_modis_blue + band_name : "red_reflectance" + NIR : + <<: *bdc_modis_blue + band_name : "NIR_reflectance" + MIR : + <<: *bdc_modis_blue + band_name : "MIR_reflectance" + CLOUD : &bdc_modis_cloud + bit_mask : false + band_name : "pixel_reliability" + values : + 0 : "Use with confidence" + 1 : "Useful, but look at other QA information" + 2 : "Target covered with snow/ice" + 3 : "Target not visible, covered with cloud" + 255 : "Fill/No Data-Not Processed" + interp_values : [2, 3, 255] + resolution : 231.656 + data_type : "INT1U" + satellite : "TERRA" + sensor : "MODIS" + collection_name: "MOD13Q1-6" + token_vars : ["BDC_ACCESS_KEY"] + open_data : true + open_data_token: true + metadata_search : "tile" + ext_tolerance: 0.01 + grid_system : "STG" + MYD13Q1-6 : + <<: *bdc_mod + satellite : "AQUA" + sensor : "MODIS" + collection_name: "MYD13Q1-6" + open_data : true + open_data_token: true + metadata_search : "tile" + ext_tolerance: 0.01 + grid_system : "STG" + SENTINEL-2-16D : &bdc_s2 + bands : + NDVI : &bdc_msi_ndvi + missing_value : -9999 + minimum_value : -10000 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 10 + band_name : "NDVI" + data_type : "INT2S" + EVI : + <<: *bdc_msi_ndvi + band_name : "EVI" + NBR : + <<: *bdc_msi_ndvi + band_name : "NBR" + B01 : &bdc_msi_band1 + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 10 + band_name : "B01" + data_type : "INT2S" + B02 : + <<: *bdc_msi_band1 + band_name : "B02" + B03 : + <<: *bdc_msi_band1 + band_name : "B03" + B04 : + <<: *bdc_msi_band1 + band_name : "B04" + B05 : + <<: *bdc_msi_band1 + band_name : "B05" + B06 : + <<: *bdc_msi_band1 + band_name : "B06" + B07 : + <<: *bdc_msi_band1 + band_name : "B07" + B08 : + <<: *bdc_msi_band1 + band_name : "B08" + B8A : + <<: *bdc_msi_band1 + band_name : "B8A" + B09 : + <<: *bdc_msi_band1 + band_name : "B09" + B11 : + <<: *bdc_msi_band1 + band_name : "B11" + B12 : + <<: *bdc_msi_band1 + band_name : "B12" + CLOUD : + bit_mask : false + band_name : "SCL" + values : + 0 : "missing_data" + 1 : "defective pixel" + 2 : "shadows" + 3 : "cloud shadows" + 4 : "vegetation" + 5 : "non-vegetated" + 6 : "water" + 7 : "unclassified" + 8 : "cloud medium" + 9 : "cloud high" + 10 : "thin cirrus" + 11 : "snow or ice" + interp_values: [0, 1, 2, 3, 8, 9, 10, 11] + resolution : 10 + data_type : "INT1U" + satellite : "SENTINEL-2" + sensor : "MSI" + collection_name: "S2-16D-2" + token_vars : ["BDC_ACCESS_KEY"] + open_data : true + open_data_token: true + metadata_search : "tile" + ext_tolerance: 0.01 + grid_system : "BDC-Small V2" diff --git a/inst/extdata/config_source_cdse.yml b/inst/extdata/config_source_cdse.yml new file mode 100644 index 000000000..9184dc35a --- /dev/null +++ b/inst/extdata/config_source_cdse.yml @@ -0,0 +1,143 @@ +# These are configuration parameters that can be set by users +# The parameters enable access to the cloud collections + +sources: + CDSE : + s3_class : ["cdse_cube", "stac_cube", "eo_cube", + "raster_cube"] + service : "STAC" + url : "https://catalogue.dataspace.copernicus.eu/resto/api/collections" + collections : + SENTINEL-1-RTC : &cdse_s1_rtc + bands : + VV : &cdse_rtc_10m + missing_value : -32768.0 + minimum_value : 0 + maximum_value : 65534 + scale_factor : 1 + offset_value : 0 + resolution : 10 + band_name : "VV" + data_type : "FLT4S" + pattern : ".*_VV\\.tif$" + VH : + <<: *cdse_rtc_10m + band_name : "VH" + pattern : ".*_VH\\.tif$" + satellite : "SENTINEL-1" + sensor : "RTC" + orbits : ["ascending", "descending"] + platforms : + SENTINEL-1A: "Sentinel-1A" + SENTINEL-1B: "Sentinel-1B" + collection_name: "SENTINEL-1-RTC" + sar_cube: true + open_data: true + open_data_token: true + metadata_search: "feature" + ext_tolerance: 0 + grid_system : "MGRS" + item_type : "RTC" + SENTINEL-2-L2A : &cdse_msi + bands : + B01 : &cdse_msi_60m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 60 + band_name : "B01" + data_type : "INT2U" + pattern : ".*B01_60m\\.jp2$" + B02 : &cdse_msi_10m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 10 + band_name : "B02" + data_type : "INT2U" + pattern : ".*B02_10m\\.jp2$" + B03 : + <<: *cdse_msi_10m + band_name : "B03" + pattern : ".*B03_10m\\.jp2$" + B04 : + <<: *cdse_msi_10m + band_name : "B04" + pattern : ".*B04_10m\\.jp2$" + B05 : &cdse_msi_20m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 20 + band_name : "B05" + data_type : "INT2U" + pattern : ".*B05_20m\\.jp2$" + B06 : + <<: *cdse_msi_20m + band_name : "B06" + pattern : ".*B06_20m\\.jp2$" + B07 : + <<: *cdse_msi_20m + band_name : "B07" + pattern : ".*B07_20m\\.jp2$" + B08 : + <<: *cdse_msi_10m + band_name : "B08" + pattern : ".*B08_10m\\.jp2$" + B8A : + <<: *cdse_msi_20m + band_name : "B8A" + pattern : ".*B8A_20m\\.jp2$" + B09 : + <<: *cdse_msi_60m + band_name : "B09" + pattern : ".*B09_60m\\.jp2$" + B11 : + <<: *cdse_msi_20m + band_name : "B11" + pattern : ".*B11_20m\\.jp2$" + B12 : + <<: *cdse_msi_20m + band_name : "B12" + pattern : ".*B12_20m\\.jp2$" + CLOUD : + bit_mask : false + band_name : "CLOUD" + values : + 0 : "missing_data" + 1 : "defective pixel" + 2 : "shadows" + 3 : "cloud shadows" + 4 : "vegetation" + 5 : "non-vegetated" + 6 : "water" + 7 : "unclassified" + 8 : "cloud medium" + 9 : "cloud high" + 10 : "thin cirrus" + 11 : "snow or ice" + interp_values : [0, 1, 2, 3, 8, 9, 10, 11] + resolution : 20 + data_type : "INT1U" + pattern : ".*SCL_20m\\.jp2$" + satellite : "SENTINEL-2" + sensor : "MSI" + platforms : + SENTINEL-2A: "Sentinel-2A" + SENTINEL-2B: "Sentinel-2B" + access_vars: + AWS_S3_ENDPOINT : "eodata.dataspace.copernicus.eu" + AWS_VIRTUAL_HOSTING : "FALSE" + collection_name: "SENTINEL-2" + open_data: true + open_data_token: true + metadata_search : "tile" + ext_tolerance: 0 + grid_system : "MGRS" + item_type : "S2MSI2A" diff --git a/inst/extdata/config_source_deafrica.yml b/inst/extdata/config_source_deafrica.yml new file mode 100644 index 000000000..ac05226ab --- /dev/null +++ b/inst/extdata/config_source_deafrica.yml @@ -0,0 +1,488 @@ +# These are configuration parameters that can be set by users +# The parameters enable access to the cloud collections + +sources: + DEAFRICA : + s3_class : ["deafrica_cube", "stac_cube", "eo_cube", + "raster_cube"] + service : "STAC" + url : "https://explorer.digitalearth.africa/stac/" + collections : + ALOS_PALSAR_MOSAIC : + bands : + HH : &deafrica_alos_25m + missing_value : 0 + minimum_value : 0 + maximum_value : 65534 + scale_factor : 1 + offset_value : 0 + resolution : 25 + band_name : "hh" + data_type : "FLT4S" + HV : + <<: *deafrica_alos_25m + band_name : "hv" + CLOUD: + band_name: "mask" + resolution: 10 + data_type: "INT1U" + bit_mask: true + values: + 0 : "no_data" + 50 : "water" + 100 : "lay_over" + 150 : "shadowing" + 255 : "land" + interp_values: [0, 150] + satellite : "PALSAR" + sensor : "ALOS" + access_vars: + AWS_DEFAULT_REGION: "af-south-1" + AWS_S3_ENDPOINT: "s3.af-south-1.amazonaws.com" + AWS_NO_SIGN_REQUEST: true + collection_name: "alos_palsar_mosaic" + open_data: true + open_data_token: false + metadata_search: "feature" + ext_tolerance: 0 + grid_system : "" + + DEM_COP_30: + bands: + ELEVATION: + band_name : "elevation" + resolution : 30 + data_type : "FLT4S" + missing_value : -32768 + minimum_value : 0 + maximum_value : 65534 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + satellite : "COP-DEM" + sensor : "30" + collection_name : "dem_cop_30" + access_vars : + AWS_DEFAULT_REGION : "af-south-1" + AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data : true + open_data_token : false + metadata_search : "tile" + ext_tolerance : 0 + grid_system : "" + + LS5_SR : + bands : + B01 : &deafrica_ls5_30m + band_name : "SR_B1" + resolution : 30 + data_type : "INT2U" + missing_value : 0 + minimum_value : 1 + maximum_value : 65455 + scale_factor : 2.75e-05 + offset_value : -0.2 + resampling : "bilinear" + B02 : + <<: *deafrica_ls5_30m + band_name: "SR_B2" + B03 : + <<: *deafrica_ls5_30m + band_name: "SR_B3" + B04 : + <<: *deafrica_ls5_30m + band_name: "SR_B4" + B05 : + <<: *deafrica_ls5_30m + band_name: "SR_B5" + B07 : + <<: *deafrica_ls5_30m + band_name: "SR_B7" + CLOUD : + band_name : "QA_PIXEL" + resolution : 30 + data_type : "INT2U" + bit_mask : true + values : + 0 : "missing_data" + 1 : "Dilated Cloud" + 2 : "Unused" + 3 : "Cloud" + 4 : "Cloud Shadow" + 5 : "Snow" + 6 : "Clear" + 7 : "Water" + 8 : "Cloud Confidence" + 9 : "Cloud Confidence" + 10 : "Cloud Shadow Confidence" + 11 : "Cloud Shadow Confidence" + 12 : "Snow/Ice Confidence" + 13 : "Snow/Ice Confidence" + 14 : "Unused" + 15 : "Unused" + interp_values: [0, 1, 3, 4, 5] + satellite : "LANDSAT-5" + sensor : "TM-MSS" + collection_name : "ls5_sr" + access_vars : + AWS_DEFAULT_REGION : "af-south-1" + AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data : true + open_data_token : false + metadata_search : "tile" + ext_tolerance : 0 + grid_system : "WRS-2" + LS7_SR : + bands : + B01 : &deafrica_ls7_30m + band_name : "SR_B1" + resolution : 30 + data_type : "INT2U" + missing_value : 0 + minimum_value : 1 + maximum_value : 65455 + scale_factor : 2.75e-05 + offset_value : -0.2 + resampling : "bilinear" + B02 : + <<: *deafrica_ls7_30m + band_name: "SR_B2" + B03 : + <<: *deafrica_ls7_30m + band_name: "SR_B3" + B04 : + <<: *deafrica_ls7_30m + band_name: "SR_B4" + B05 : + <<: *deafrica_ls7_30m + band_name: "SR_B5" + B07 : + <<: *deafrica_ls7_30m + band_name: "SR_B7" + CLOUD : + band_name : "QA_PIXEL" + resolution : 30 + data_type : "INT2U" + bit_mask : true + values : + 0 : "missing_data" + 1 : "Dilated Cloud" + 2 : "Unused" + 3 : "Cloud" + 4 : "Cloud Shadow" + 5 : "Snow" + 6 : "Clear" + 7 : "Water" + 8 : "Cloud Confidence" + 9 : "Cloud Confidence" + 10 : "Cloud Shadow Confidence" + 11 : "Cloud Shadow Confidence" + 12 : "Snow/Ice Confidence" + 13 : "Snow/Ice Confidence" + 14 : "Unused" + 15 : "Unused" + interp_values: [0, 1, 3, 4, 5] + satellite : "LANDSAT-7" + sensor : "ETM" + collection_name : "ls7_sr" + access_vars : + AWS_DEFAULT_REGION : "af-south-1" + AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data : true + open_data_token : false + metadata_search : "tile" + ext_tolerance : 0 + grid_system : "WRS-2" + LS8_SR : &deafrica_l8 + bands : + B01 : &deafrica_oli_30m + missing_value : 0 + minimum_value : 7273 + maximum_value : 43636 + scale_factor : 0.0000275 + offset_value : -0.2 + resampling : "bilinear" + resolution : 30 + band_name : "SR_B1" + data_type : "INT2U" + B02 : + <<: *deafrica_oli_30m + band_name : "SR_B2" + B03 : + <<: *deafrica_oli_30m + band_name : "SR_B3" + B04 : + <<: *deafrica_oli_30m + band_name : "SR_B4" + B05 : + <<: *deafrica_oli_30m + band_name : "SR_B5" + B06 : + <<: *deafrica_oli_30m + band_name : "SR_B6" + B07 : + <<: *deafrica_oli_30m + band_name : "SR_B7" + CLOUD : + bit_mask : true + band_name : "QA_PIXEL" + values : + 0 : "missing_data" + 1 : "Dilated Cloud" + 2 : "High confidence cirrus" + 4 : "High confidence cloud shadow" + 5 : "High confidence snow cover" + 6 : "Clear" + 7 : "Water" + 9 : "High confidence of cloud" + 11 : "High confidence of cloud shadow" + 13 : "High confidence of snow" + 15 : "High confidence of cirrus" + interp_values : [0, 1, 2, 3, 4, 5] + resampling : "near" + resolution : 30 + data_type : "INT2U" + satellite : "LANDSAT-8" + sensor : "OLI" + collection_name: "ls8_sr" + access_vars : + AWS_DEFAULT_REGION: "af-south-1" + AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" + AWS_NO_SIGN_REQUEST: true + open_data: true + open_data_token: false + metadata_search : "feature" + ext_tolerance: 0 + grid_system : "WRS-2" + LS9_SR : + bands: + B01: &deafrica_ls9_30m + band_name : "SR_B1" + resolution : 30 + data_type : "INT2U" + missing_value : 0 + minimum_value : 1 + maximum_value : 65455 + scale_factor : 2.75e-05 + offset_value : -0.2 + resampling : "bilinear" + B02: + <<: *deafrica_ls9_30m + band_name: "SR_B2" + B03: + <<: *deafrica_ls9_30m + band_name: "SR_B3" + B04: + <<: *deafrica_ls9_30m + band_name: "SR_B4" + B05: + <<: *deafrica_ls9_30m + band_name: "SR_B5" + B06: + <<: *deafrica_ls9_30m + band_name: "SR_B6" + B07: + <<: *deafrica_ls9_30m + band_name: "SR_B7" + CLOUD: + band_name : "QA_PIXEL" + resolution : 30 + data_type : "INT2U" + bit_mask : true + values : + 0 : "missing_data" + 1 : "Dilated Cloud" + 2 : "Cirrus" + 3 : "Cloud" + 4 : "Cloud Shadow" + 5 : "Snow" + 6 : "Clear" + 7 : "Water" + 8 : "Cloud Confidence" + 9 : "Cloud Confidence" + 10 : "Cloud Shadow Confidence" + 11 : "Cloud Shadow Confidence" + 12 : "Snow/Ice Confidence" + 13 : "Snow/Ice Confidence" + 14 : "Cirrus Confidence" + 15 : "Cirrus Confidence" + interp_values : [0, 1, 2, 3, 4, 5] + satellite : "LANDSAT-9" + sensor : "OLI" + collection_name : "ls9_sr" + access_vars : + AWS_DEFAULT_REGION : "af-south-1" + AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data : true + open_data_token : false + metadata_search : "tile" + ext_tolerance : 0 + grid_system : "WRS-2" + + NDVI_ANOMALY : + bands : + NDVI-MEAN : &deafrica_ndvi_anomaly_30m + band_name : "ndvi_mean" + resolution : 30 + data_type : "FLT4S" + missing_value : -32768 + minimum_value : 0 + maximum_value : 1 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + NDVI-STD-ANOMALY: + <<: *deafrica_ndvi_anomaly_30m + band_name : "ndvi_std_anomaly" + satellite : "LANDSAT-SENTINEL" + sensor : "OLI-MSI" + collection_name : "ndvi_anomaly" + access_vars: + AWS_DEFAULT_REGION : "af-south-1" + AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data : true + open_data_token : false + metadata_search : "tile" + ext_tolerance : 0 + grid_system : "" + RAINFALL_CHIRPS_DAILY : + bands: + RAINFALL: + band_name : "rainfall" + resolution : 5000 + data_type : "FLT4S" + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + satellite : "CHIRPS" + sensor : "CHIRPS" + collection_name : "rainfall_chirps_daily" + access_vars : + AWS_DEFAULT_REGION : "af-south-1" + AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data : true + open_data_token : false + metadata_search : "feature" + ext_tolerance : 0 + grid_system : "" + RAINFALL_CHIRPS_MONTHLY : + bands: + RAINFALL: + band_name : "rainfall" + resolution : 5000 + data_type : "FLT4S" + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + satellite : "CHIRPS" + sensor : "CHIRPS" + collection_name : "rainfall_chirps_monthly" + access_vars : + AWS_DEFAULT_REGION : "af-south-1" + AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data : true + open_data_token : false + metadata_search : "feature" + ext_tolerance : 0 + grid_system : "" + + S2_L2A : + bands : + B01 : &deafrica_msi_60m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 60 + band_name : "B01" + data_type : "INT2S" + B02 : &deafrica_msi_10m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 10 + band_name : "B02" + data_type : "INT2S" + B03 : + <<: *deafrica_msi_10m + band_name : "B03" + B04 : + <<: *deafrica_msi_10m + band_name : "B04" + B05 : &deafrica_msi_20m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 20 + band_name : "B05" + data_type : "INT2S" + B06 : + <<: *deafrica_msi_20m + band_name : "B06" + B07 : + <<: *deafrica_msi_20m + band_name : "B07" + B08 : + <<: *deafrica_msi_10m + band_name : "B08" + B8A : + <<: *deafrica_msi_20m + band_name : "B8A" + B09 : + <<: *deafrica_msi_60m + band_name : "B09" + B11 : + <<: *deafrica_msi_20m + band_name : "B11" + B12 : + <<: *deafrica_msi_20m + band_name : "B12" + CLOUD : + bit_mask : false + band_name : "SCL" + values : + 0 : "missing_data" + 1 : "defective pixel" + 2 : "shadows" + 3 : "cloud shadows" + 4 : "vegetation" + 5 : "non-vegetated" + 6 : "water" + 7 : "unclassified" + 8 : "cloud medium" + 9 : "cloud high" + 10 : "thin cirrus" + 11 : "snow or ice" + interp_values : [0, 1, 2, 3, 8, 9, 10, 11] + resolution : 20 + data_type : "INT1U" + satellite : "SENTINEL-2" + sensor : "MSI" + collection_name: "s2_l2a" + access_vars : + AWS_DEFAULT_REGION: "af-south-1" + AWS_S3_ENDPOINT : "s3.af-south-1.amazonaws.com" + AWS_NO_SIGN_REQUEST: true + open_data: true + open_data_token: false + metadata_search : "tile" + ext_tolerance: 0 + grid_system : "MGRS" diff --git a/inst/extdata/config_source_hls.yml b/inst/extdata/config_source_hls.yml new file mode 100644 index 000000000..ad3322342 --- /dev/null +++ b/inst/extdata/config_source_hls.yml @@ -0,0 +1,142 @@ +# These are configuration parameters that can be set by users +# The parameters enable access to the cloud collections + +HLS_ACCESS_URL: "machine.urs.earthdata.nasa.gov" + +sources: + HLS : + s3_class : ["hls_cube", "stac_cube", "eo_cube", + "raster_cube"] + service : "STAC" + rstac_version : "1.0.0" + url : "https://cmr.earthdata.nasa.gov/stac/LPCLOUD" + collections : + HLSS30 : + bands : + COASTAL-AEROSOL: &hls_s2_30m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 30 + band_name : "B01" + data_type : "INT2S" + BLUE : + <<: *hls_s2_30m + band_name : "B02" + GREEN : + <<: *hls_s2_30m + band_name : "B03" + RED : + <<: *hls_s2_30m + band_name : "B04" + RED-EDGE-1: + <<: *hls_s2_30m + band_name : "B05" + RED-EDGE-2: + <<: *hls_s2_30m + band_name : "B06" + RED-EDGE-3: + <<: *hls_s2_30m + band_name : "B07" + NIR-BROAD: + <<: *hls_s2_30m + band_name : "B08" + NIR-NARROW: + <<: *hls_s2_30m + band_name : "B8A" + WATER-VAPOR: + <<: *hls_s2_30m + band_name : "B09" + SWIR-1 : + <<: *hls_s2_30m + band_name : "B11" + SWIR-2 : + <<: *hls_s2_30m + band_name : "B12" + CLOUD : + bit_mask : true + band_name : "Fmask" + values : + 0 : "Cirrus" + 1 : "Cloud" + 2 : "Adjacent to cloud/shadow" + 3 : "Cloud shadow" + 4 : "Snow/ice" + 5 : "Water" + 6 : "Aerosol level (low)" + 7 : "Aerosol level (moderate or high)" + interp_values : [1, 2, 3, 4, 7] + resampling : "near" + resolution : 30 + data_type : "INT1U" + satellite : "SENTINEL-2" + sensor : "MSI" + collection_name: "HLSS30.v2.0" + access_vars : + GDAL_HTTP_UNSAFESSL: "YES" + GDAL_HTTP_COOKIEFILE: ".rcookies" + GDAL_HTTP_COOKIEJAR: ".rcookies" + open_data: true + open_data_token: false + metadata_search : "tile" + ext_tolerance: 0 + grid_system : "MGRS" + HLSL30 : + bands : + COASTAL-AEROSOL: &hls_l8_30m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 30 + band_name : "B01" + data_type : "INT2S" + BLUE : + <<: *hls_l8_30m + band_name : "B02" + GREEN : + <<: *hls_l8_30m + band_name : "B03" + RED : + <<: *hls_l8_30m + band_name : "B04" + NIR-NARROW: + <<: *hls_l8_30m + band_name : "B05" + SWIR-1 : + <<: *hls_l8_30m + band_name : "B06" + SWIR-2 : + <<: *hls_l8_30m + band_name : "B07" + CLOUD : + bit_mask : true + band_name : "Fmask" + values : + 0 : "Cirrus" + 1 : "Cloud" + 2 : "Adjacent to cloud/shadow" + 3 : "Cloud shadow" + 4 : "Snow/ice" + 5 : "Water" + 6 : "Aerosol level (low)" + 7 : "Aerosol level (moderate or high)" + interp_values : [1, 2, 3, 4, 7] + resampling : "near" + resolution : 30 + data_type : "INT1U" + satellite : "LANDSAT-8" + sensor : "OLI" + collection_name: "hlsl30.v2.0" + access_vars : + GDAL_HTTP_UNSAFESSL: "YES" + GDAL_HTTP_COOKIEFILE: ".rcookies" + GDAL_HTTP_COOKIEJAR: ".rcookies" + open_data: true + open_data_token: false + metadata_search : "tile" + ext_tolerance: 0 + grid_system : "MGRS" diff --git a/inst/extdata/config_source_mpc.yml b/inst/extdata/config_source_mpc.yml new file mode 100644 index 000000000..320b3abbc --- /dev/null +++ b/inst/extdata/config_source_mpc.yml @@ -0,0 +1,219 @@ +# These are configuration parameters that can be set by users +# The parameters enable access to the cloud collections + +sources: + MPC : + s3_class : ["mpc_cube", "stac_cube", "eo_cube", + "raster_cube"] + service : "STAC" + rstac_version : "1.0.0" + url : "https://planetarycomputer.microsoft.com/api/stac/v1" + token_url : "https://planetarycomputer.microsoft.com/api/sas/v1/token" + collections : + LANDSAT-C2-L2 : &mspc_oli + bands : + BLUE : &mspc_oli_30m + missing_value : 0 + minimum_value : 7273 + maximum_value : 43636 + scale_factor : 0.0000275 + offset_value : -0.2 + resampling : "bilinear" + resolution : 30 + band_name : "blue" + data_type : "INT2U" + GREEN : + <<: *mspc_oli_30m + band_name : "green" + RED : + <<: *mspc_oli_30m + band_name : "red" + NIR08 : + <<: *mspc_oli_30m + band_name : "nir08" + SWIR16 : + <<: *mspc_oli_30m + band_name : "swir16" + SWIR22 : + <<: *mspc_oli_30m + band_name : "swir22" + CLOUD : + bit_mask : true + band_name : "qa_pixel" + values : + 0 : "Missing data" + 1 : "Dilated Cloud" + 2 : "High confidence cirrus" + 3 : "High confidence cloud" + 4 : "High confidence cloud shadow" + 5 : "High confidence snow cover" + 6 : "Clear" + 7 : "Water" + 8 : "Low/High confidence of cloud" + 9 : "Medium/High confidence of cloud" + 10 : "Low/High confidence of cloud shadow" + 11 : "Medium/High confidence of cloud shadow" + 12 : "Low/High confidence of snow" + 13 : "Medium/High confidence of snow" + 14 : "Low/High confidence of cirrus" + 15 : "Medium/High confidence of cirrus" + interp_values : [0, 1, 2, 3, 4, 5, 9, 11, 13, 15] + resampling : "near" + resolution : 30 + data_type : "INT2U" + satellite : "LANDSAT" + sensor : "TM-ETM-OLI" + platforms : + LANDSAT-5: "landsat-5" + LANDSAT-7: "landsat-7" + LANDSAT-8: "landsat-8" + LANDSAT-9: "landsat-9" + collection_name: "landsat-c2-l2" + open_data: true + open_data_token: false + tile_required: false + metadata_search : "feature" + ext_tolerance: 0 + grid_system : "WRS-2" + SENTINEL-2-L2A : &mspc_msi + bands : + B01 : &mspc_msi_60m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 60 + band_name : "B01" + data_type : "INT2S" + B02 : &mspc_msi_10m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 10 + band_name : "B02" + data_type : "INT2S" + B03 : + <<: *mspc_msi_10m + band_name : "B03" + B04 : + <<: *mspc_msi_10m + band_name : "B04" + B05 : &mspc_msi_20m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 20 + band_name : "B05" + data_type : "INT2S" + B06 : + <<: *mspc_msi_20m + band_name : "B06" + B07 : + <<: *mspc_msi_20m + band_name : "B07" + B08 : + <<: *mspc_msi_10m + band_name : "B08" + B8A : + <<: *mspc_msi_20m + band_name : "B8A" + B09 : + <<: *mspc_msi_60m + band_name : "B09" + B11 : + <<: *mspc_msi_20m + band_name : "B11" + B12 : + <<: *mspc_msi_20m + band_name : "B12" + CLOUD : + bit_mask : false + band_name : "SCL" + values : + 0 : "missing_data" + 1 : "defective pixel" + 2 : "shadows" + 3 : "cloud shadows" + 4 : "vegetation" + 5 : "non-vegetated" + 6 : "water" + 7 : "unclassified" + 8 : "cloud medium" + 9 : "cloud high" + 10 : "thin cirrus" + 11 : "snow or ice" + interp_values : [0, 1, 2, 3, 8, 9, 10, 11] + resolution : 20 + data_type : "INT1U" + satellite : "SENTINEL-2" + sensor : "MSI" + platforms : + SENTINEL-2A: "Sentinel-2A" + SENTINEL-2B: "Sentinel-2B" + collection_name: "sentinel-2-l2a" + open_data: true + open_data_token: false + metadata_search : "tile" + ext_tolerance: 0 + grid_system : "MGRS" + SENTINEL-1-GRD : &mspc_s1_grd + bands : + VV : &mspc_grd_10m + missing_value : 0 + minimum_value : 1 + maximum_value : 65534 + scale_factor : 0.001 + offset_value : 0 + resolution : 10 + band_name : "vv" + data_type : "INT2U" + VH : + <<: *mspc_grd_10m + band_name : "vh" + satellite : "SENTINEL-1" + sensor : "C-band-SAR" + orbits : ["ascending", "descending"] + platforms : + SENTINEL-1A: "Sentinel-1A" + SENTINEL-1B: "Sentinel-1B" + collection_name: "sentinel-1-grd" + sar_cube: true + open_data: true + open_data_token: false + metadata_search: "feature" + ext_tolerance: 0 + grid_system : "MGRS" + SENTINEL-1-RTC : &mspc_s1_rtc + bands : + VV : &mspc_rtc_10m + missing_value : -32768.0 + minimum_value : 0 + maximum_value : 65534 + scale_factor : 1 + offset_value : 0 + resolution : 10 + band_name : "vv" + data_type : "FLT4S" + VH : + <<: *mspc_rtc_10m + band_name : "vh" + satellite : "SENTINEL-1" + sensor : "C-band-SAR" + orbits : ["ascending", "descending"] + platforms : + SENTINEL-1A: "Sentinel-1A" + SENTINEL-1B: "Sentinel-1B" + collection_name: "sentinel-1-rtc" + sar_cube: true + open_data: false + open_data_token: false + metadata_search: "feature" + ext_tolerance: 0 + grid_system : "MGRS" + token_vars : ["MPC_TOKEN"] + diff --git a/inst/extdata/config_source_sdc.yml b/inst/extdata/config_source_sdc.yml new file mode 100644 index 000000000..2535ba01f --- /dev/null +++ b/inst/extdata/config_source_sdc.yml @@ -0,0 +1,144 @@ +# These are configuration parameters that can be set by users +# The parameters enable access to the cloud collections + +sources: + SDC : + s3_class : ["sdc_cube", "stac_cube", "eo_cube", + "raster_cube"] + service : "STAC" + url : "https://explorer.swissdatacube.org/stac" + collections : + S2_L2A_10M_SWISS: &swiss_s2 + bands : + B01 : &swiss_msi_10m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 10 + band_name : "coastal_aerosol" + data_type : "INT2S" + B02 : + <<: *swiss_msi_10m + band_name : "blue" + B03 : + <<: *swiss_msi_10m + band_name : "green" + B04 : + <<: *swiss_msi_10m + band_name : "red" + B05 : + <<: *swiss_msi_10m + band_name : "veg5" + B06 : + <<: *swiss_msi_10m + band_name : "veg6" + B07 : + <<: *swiss_msi_10m + band_name : "veg7" + B08 : + <<: *swiss_msi_10m + band_name : "nir" + B8A : + <<: *swiss_msi_10m + band_name : "narrow_nir" + B09 : + <<: *swiss_msi_10m + band_name : "water_vapour" + B11 : + <<: *swiss_msi_10m + band_name : "swir1" + B12 : + <<: *swiss_msi_10m + band_name : "swir2" + CLOUD : + bit_mask : false + band_name : "scl" + values : + 0 : "missing_data" + 1 : "defective pixel" + 2 : "shadows" + 3 : "cloud shadows" + 4 : "vegetation" + 5 : "non-vegetated" + 6 : "water" + 7 : "unclassified" + 8 : "cloud medium" + 9 : "cloud high" + 10 : "thin cirrus" + 11 : "snow or ice" + interp_values : [0, 1, 2, 3, 8, 9, 10, 11] + resolution : 20 + data_type : "INT1U" + satellite : "SENTINEL-2" + sensor : "MSI" + collection_name: "s2_l2a_10m_swiss" + open_data: true + open_data_token: false + metadata_search : "feature" + ext_tolerance: 0 + grid_system : "MGRS" + LS8_LASRC_SWISS : &swiss_l8 + bands : + B01 : &swiss_oli_30m + missing_value : -9999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "coastal_aerosol" + data_type : "INT2S" + B02 : + <<: *swiss_oli_30m + band_name : "blue" + B03 : + <<: *swiss_oli_30m + band_name : "green" + B04 : + <<: *swiss_oli_30m + band_name : "red" + B05 : + <<: *swiss_oli_30m + band_name : "nir" + B06 : + <<: *swiss_oli_30m + band_name : "swir1" + B07 : + <<: *swiss_oli_30m + band_name : "swir2" + CLOUD : + bit_mask : true + band_name : "pixel_qa" + values : + 0 : "missing_data" + 1 : "Clear" + 2 : "Water" + 3 : "Cloud Shadow" + 4 : "Snow" + 5 : "Cloud" + 6 : "Low/High confidence of cloud" + 7 : "Medium/High confidence of cloud" + 8 : "Low/High confidence of cirrus" + 9 : "Medium/High confidence of cirrus" + 10 : "Terrain Occlusion" + 11 : "Unused" + 12 : "Unused" + 13 : "Unused" + 14 : "Unused" + 15 : "Unused" + interp_values : [0, 3, 4, 5, 7, 9, 10] + resampling : "near" + resolution : 30 + data_type : "INT2U" + satellite : "LANDSAT-8" + sensor : "OLI" + collection_name: "ls8_lasrc_swiss" + open_data: true + open_data_token: false + metadata_search : "feature" + ext_tolerance: 0 + grid_system : "WRS-2" + diff --git a/inst/extdata/config_source_usgs.yml b/inst/extdata/config_source_usgs.yml new file mode 100644 index 000000000..a42fe5bc8 --- /dev/null +++ b/inst/extdata/config_source_usgs.yml @@ -0,0 +1,81 @@ +# These are configuration parameters that can be set by users +# The parameters enable access to the cloud collections + +sources: + USGS : + s3_class : ["usgs_cube", "stac_cube", "eo_cube", + "raster_cube"] + service : "STAC" + rstac_version : "0.9.0" + url : "https://landsatlook.usgs.gov/stac-server" + collections : + LANDSAT-C2L2-SR : &usgs_oli + bands : + BLUE : &usgs_oli_30m + missing_value : 0 + minimum_value : 7273 + maximum_value : 43636 + scale_factor : 0.0000275 + offset_value : -0.2 + resampling : "bilinear" + resolution : 30 + band_name : "blue" + data_type : "INT2U" + GREEN : + <<: *usgs_oli_30m + band_name : "green" + RED : + <<: *usgs_oli_30m + band_name : "red" + NIR08 : + <<: *usgs_oli_30m + band_name : "nir08" + SWIR16 : + <<: *usgs_oli_30m + band_name : "swir16" + SWIR22 : + <<: *usgs_oli_30m + band_name : "swir22" + CLOUD : + bit_mask : true + band_name : "qa_pixel" + values : + 0 : "Missing data" + 1 : "Dilated Cloud" + 2 : "High confidence cirrus" + 3 : "High confidence cloud" + 4 : "High confidence cloud shadow" + 5 : "High confidence snow cover" + 6 : "Clear" + 7 : "Water" + 8 : "Low/High confidence of cloud" + 9 : "Medium/High confidence of cloud" + 10 : "Low/High confidence of cloud shadow" + 11 : "Medium/High confidence of cloud shadow" + 12 : "Low/High confidence of snow" + 13 : "Medium/High confidence of snow" + 14 : "Low/High confidence of cirrus" + 15 : "Medium/High confidence of cirrus" + interp_values : [0, 1, 2, 3, 4, 5, 9, 11, 13, 15] + resampling : "near" + resolution : 30 + data_type : "INT2U" + satellite : "LANDSAT" + sensor : "TM/ETM+/OLI" + platforms : + LANDSAT-5: "LANDSAT_5" + LANDSAT-7: "LANDSAT_7" + LANDSAT-8: "LANDSAT_8" + LANDSAT-9: "LANDSAT_9" + collection_name: "landsat-c2l2-sr" + access_vars : + AWS_DEFAULT_REGION: "us-west-2" + AWS_S3_ENDPOINT : "s3.amazonaws.com" + AWS_REQUEST_PAYER : "requester" + AWS_NO_SIGN_REQUEST : false + open_data: false + open_data_token: false + tile_required: false + metadata_search : "feature" + ext_tolerance: 0 + grid_system : "WRS-2" From c7d5db76407674a4a7171ec6e7cfb09381a9ffa8 Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Mon, 22 Apr 2024 16:53:11 -0300 Subject: [PATCH 02/11] add support to new deafrica products --- R/api_source_deafrica.R | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/R/api_source_deafrica.R b/R/api_source_deafrica.R index 04db9e066..0816a80dc 100644 --- a/R/api_source_deafrica.R +++ b/R/api_source_deafrica.R @@ -93,12 +93,6 @@ .check_stac_items(items_info) return(items_info) } -#' @title Organizes items by tiles for DEAfrica collections -#' @param source Name of the STAC provider. -#' @param ... Other parameters to be passed for specific types. -#' @param items \code{STACItemcollection} object from rstac package. -#' @param collection Collection to be searched in the data source. -#' @return A list of items. #' @keywords internal #' @noRd #' @export @@ -107,3 +101,36 @@ collection = NULL) { rstac::items_reap(items, field = c("properties", "odc:region_code")) } +#' @keywords internal +#' @noRd +#' @export +.source_item_get_date.deafrica_cube <- function(source, + item, + ..., + collection = NULL) { + item_date <- item[[c("properties", "datetime")]] + + # Digital Earth Africa provides some products with the `properties.datetime` + # property `null`. In those cases, it is required to use other date + # parameter available + if (is.null(item_date)) + item_date <- item[[c("properties", "start_datetime")]] + + suppressWarnings( + lubridate::as_date(item_date) + ) +} +#' @keywords internal +#' @noRd +#' @export +`.source_items_tile.deafrica_cube_rainfall_chirps_daily` <- + function(source, items, ..., collection = NULL) { + rep("NoTilingSystem", rstac::items_length(items)) +} +#' @keywords internal +#' @noRd +#' @export +`.source_items_tile.deafrica_cube_rainfall_chirps_monthly` <- + function(source, items, ..., collection = NULL) { + rep("NoTilingSystem", rstac::items_length(items)) +} From 74efcffc67375a6db90b9414da11acf1dd4e2764 Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Mon, 22 Apr 2024 16:53:43 -0300 Subject: [PATCH 03/11] add cdse as datasource --- DESCRIPTION | 2 + NAMESPACE | 12 + R/api_source_cdse.R | 634 +++++++++++++++++++++++++++++++++++++ R/sits_cube.R | 3 +- tests/testthat/test-cube.R | 7 + 5 files changed, 657 insertions(+), 1 deletion(-) create mode 100644 R/api_source_cdse.R diff --git a/DESCRIPTION b/DESCRIPTION index 7ae6991d5..812110063 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -64,6 +64,7 @@ Imports: torch (>= 0.11.0), utils Suggests: + aws.s3, caret, cli, covr, @@ -166,6 +167,7 @@ Collate: 'api_source.R' 'api_source_aws.R' 'api_source_bdc.R' + 'api_source_cdse.R' 'api_source_deafrica.R' 'api_source_hls.R' 'api_source_local.R' diff --git a/NAMESPACE b/NAMESPACE index f75927cf6..6b8de47d5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -126,6 +126,7 @@ S3method(.reg_s2tile_convert,grd_cube) S3method(.reg_s2tile_convert,rtc_cube) S3method(.slice_dfr,numeric) S3method(.source_collection_access_test,"mpc_cube_sentinel-1-grd") +S3method(.source_collection_access_test,cdse_cube) S3method(.source_collection_access_test,mpc_cube) S3method(.source_collection_access_test,stac_cube) S3method(.source_collection_access_test,usgs_cube) @@ -133,13 +134,17 @@ S3method(.source_cube,stac_cube) S3method(.source_filter_tiles,"mpc_cube_sentinel-1-grd") S3method(.source_filter_tiles,stac_cube) S3method(.source_item_get_bands,stac_cube) +S3method(.source_item_get_cloud_cover,cdse_cube) S3method(.source_item_get_cloud_cover,sdc_cube) S3method(.source_item_get_cloud_cover,stac_cube) +S3method(.source_item_get_date,cdse_cube) +S3method(.source_item_get_date,deafrica_cube) S3method(.source_item_get_date,stac_cube) S3method(.source_item_get_hrefs,bdc_cube) S3method(.source_item_get_hrefs,sdc_cube) S3method(.source_item_get_hrefs,stac_cube) S3method(.source_item_get_hrefs,usgs_cube) +S3method(.source_items_bands_select,cdse_cube) S3method(.source_items_bands_select,stac_cube) S3method(.source_items_cube,stac_cube) S3method(.source_items_fid,stac_cube) @@ -150,25 +155,31 @@ S3method(.source_items_new,"mpc_cube_sentinel-1-rtc") S3method(.source_items_new,"mpc_cube_sentinel-2-l2a") S3method(.source_items_new,aws_cube) S3method(.source_items_new,bdc_cube) +S3method(.source_items_new,cdse_cube) S3method(.source_items_new,deafrica_cube) S3method(.source_items_new,deafrica_cube_s2_l2a) S3method(.source_items_new,hls_cube) S3method(.source_items_new,sdc_cube) S3method(.source_items_new,usgs_cube) S3method(.source_items_tile,"aws_cube_landsat-c2-l2") +S3method(.source_items_tile,"cdse_cube_sentinel-1-rtc") S3method(.source_items_tile,"mpc_cube_landsat-c2-l2") S3method(.source_items_tile,"mpc_cube_sentinel-1-grd") S3method(.source_items_tile,"mpc_cube_sentinel-1-rtc") S3method(.source_items_tile,"mpc_cube_sentinel-2-l2a") S3method(.source_items_tile,aws_cube) S3method(.source_items_tile,bdc_cube) +S3method(.source_items_tile,cdse_cube) S3method(.source_items_tile,deafrica_cube) +S3method(.source_items_tile,deafrica_cube_rainfall_chirps_daily) +S3method(.source_items_tile,deafrica_cube_rainfall_chirps_monthly) S3method(.source_items_tile,hls_cube) S3method(.source_items_tile,sdc_cube) S3method(.source_items_tile,usgs_cube) S3method(.source_roi_tiles,"mpc_cube_landsat-c2-l2") S3method(.source_roi_tiles,sdc_cube) S3method(.source_roi_tiles,stac_cube) +S3method(.source_tile_get_bbox,"cdse_cube_sentinel-1-rtc") S3method(.source_tile_get_bbox,"mpc_cube_sentinel-1-grd") S3method(.source_tile_get_bbox,"mpc_cube_sentinel-1-rtc") S3method(.source_tile_get_bbox,stac_cube) @@ -397,6 +408,7 @@ S3method(summary,sits_accuracy) S3method(summary,sits_area_accuracy) export("sits_bands<-") export("sits_labels<-") +export(.mpc_clean_token_cache) export(impute_linear) export(sits_accuracy) export(sits_accuracy_summary) diff --git a/R/api_source_cdse.R b/R/api_source_cdse.R new file mode 100644 index 000000000..bc9e93adc --- /dev/null +++ b/R/api_source_cdse.R @@ -0,0 +1,634 @@ + +# ---- general utilities ---- +#' @title Extract item type of a given `collection`. +#' @keywords internal +#' @noRd +#' +#' @description +#' This function reads the item type of a `collection` and prepares it for use +#' in the CDSE Source API's internal methods. This is required as for some +#' `collection`, CDSE returns multiple kinds of items. +#' @param source Data source. +#' @param collection Image collection. +#' @return item type of a given `collection`. +.cdse_item_type <- function(source, collection) { + item_type <- .conf( + "sources", + source, + "collections", + collection, + "item_type" + ) + class(item_type) <- c("character", item_type) + item_type +} + +# ---- stac utilities ---- +#' @title Extract datetime from a STAC Query. +#' @keywords internal +#' @noRd +#' +#' @param stac_query Query that follows the STAC protocol. +#' @return List with `start_date` and `end_date` properties. +.stac_cdse_datetime_as_dates <- function(stac_query) { + query_datetime <- stringr::str_split( + stac_query[["params"]][["datetime"]], "/" + ) + list( + start_date = query_datetime[[1]][1], + end_date = query_datetime[[1]][2] + ) +} + +#' @title Extract bounding box from a STAC Query. +#' @keywords internal +#' @noRd +#' +#' @param stac_query Query that follows the STAC protocol. +#' @return List with `bbox` property. +.stac_cdse_intersects_as_bbox <- function(stac_query) { + result <- list(bbox = NULL) + # Extract spatial reference from STAC object + intersects <- stac_query[["params"]][["intersects"]] + coordinates <- intersects[["coordinates"]] + # Check if query is valid + if (is.null(coordinates)) { + return(result) + } + # Extract x-coordinates and y-coordinates + coordinates_x <- coordinates[,,1] + coordinates_y <- coordinates[,,2] + # Calculate bounding box + min_x <- min(coordinates_x) + max_x <- max(coordinates_x) + min_y <- min(coordinates_y) + max_y <- max(coordinates_y) + # Create bbox object + result[["bbox"]] <- c(min_x, min_y, max_x, max_y) + result +} + +#' @title Fix STAC Items from CDSE with assets metadata. +#' @keywords internal +#' @noRd +#' +#' @description +#' This auxiliary function creates `STAC Assets` for each of the bands selected +#' by user. This is necessary since CDSE STAC does not return band files as +#' `STAC Assets` The information is extracted from files available in the +#' CDSE S3 API. +#' @param source Data source. +#' @param items STAC items. +#' @param bands Band names. +#' @param collection Image collection. +#' @return STAC Items updated with `assets` property. +.stac_cdse_fix_items <- function(source, items, bands, collection, multicores) { + # Start parallel workers + .parallel_start(workers = multicores) + on.exit(.parallel_stop(), add = TRUE) + # Define path used to extract the product prefix in CDSE S3 + s3_path <- c("properties", "productIdentifier") + # Define name of the CDSE products bucket + s3_bucket <- "/eodata/" + # Define protocol to access S3 data + s3_protocol <- "/vsis3" + # CDSE does not provide files directly in the `assets` property`. As a + # workaround, we build the `assets` property using files in the CDSE S3 API + features_fixed <- .parallel_map(items[["features"]], function(feature) { + # Prepare item path in CDSE S3 + item_s3_path <- rstac::items_reap(feature, s3_path) |> + stringr::str_replace(s3_bucket, "") + # Read the item's content from CDSE S3 + item_s3_content <- aws.s3::get_bucket_df( + bucket = "eodata", + use_https = TRUE, + region = "", + prefix = item_s3_path + ) + # Extract the address of the files associated with bands selected by + # users. + item_bands <- purrr::map(bands, function(band) { + band_conf <- .conf_eo_band(source, collection, band) + # Create pattern to select file associated with the band. + band_pattern <- band_conf[["pattern"]] + # Filter the S3 content to get files from the band + band_item <- + dplyr::filter(item_s3_content, + stringr::str_detect(.data[["Key"]], band_pattern)) + # Check if the correct file was selected. + .check_that(nrow(band_item) == 1, + msg = paste0("Invalid band: ", band)) + # Prepare the file address + band_path_s3 <- paste0(s3_protocol, s3_bucket, band_item[["Key"]]) + # Prepare result and return it + # As this auxiliary function only needs to provide the right content + # to other parts of `sits`, only the `href` of the image is returned. + # The other necessary actions are managed by `sits.` + stats::setNames(list(band = list(href = band_path_s3)), band) + }) + feature[["assets"]] <- purrr::list_flatten(item_bands) + feature + }) + # Remove duplicates + features_id <- unlist(purrr::map(features_fixed, "id")) + features_fixed <- features_fixed[!duplicated(features_id)] + # Update items object + items[["features"]] <- features_fixed + items +} + +# ---- open search utilities ---- +#' @title Prepare Open Search feature as STAC Item (Compatible with `rstac`). +#' @keywords internal +#' @noRd +#' +#' @description +#' This function prepares an Open Search feature to act as an STAC Item, +#' compatible with the `rstac` package. This is required to avoid changes in +#' other parts of the `sits` validation structure and to use features +#' from `rstac`. +#' @param features List of features. +#' @param product_type Type of product associated with the features. +#' @return List of features compatible with +#' `rstac` (`rstac::doc_item`). +.opensearch_as_stac_item <- function(features, product_type) { + purrr::map(features, function(feature) { + # Use `rstac` class, including `product type` + class(feature) <- c("doc_item", "rstac_doc", "list", product_type) + # Extract tile + feature_tile <- .opensearch_cdse_extract_tile(feature) + feature_tile <- unlist(feature_tile) + # Save tile + feature[["properties"]][["tile"]] <- feature_tile + feature + }) +} + +#' @title Prepare Open Search features as STAC Items (Compatible with `rstac`). +#' @keywords internal +#' @noRd +#' +#' @description +#' This function prepares an Open Search item to act as an STAC Item, +#' compatible with the `rstac` package. This is required to avoid changes in +#' other parts of the `sits` validation structure and to use features +#' from `rstac`. +#' @param features List of features. +#' @param product_type Type of product associated with the features. +#' @return List of features compatible with +#' `rstac` (`rstac::doc_items`). +.opensearch_as_stac_items <- function(features) { + # Create `rstac` compatible object + items <- list() + # Type is required to facilitate item visualization + items[["type"]] <- "FeatureCollection" + # Include features + items[["features"]] <- features + # Include `rstac` classes + class(items) <- c("doc_items", "rstac_doc", "list") + items +} + +#' @title Query scenes available in the CDSE Open Search. +#' @keywords internal +#' @noRd +#' +#' @description +#' This auxiliary function is used to get query the CDSE Open Search API. This +#' is required as the current version of the CDSE STAC does +#' not support fields / advanced search (e.g., search by product type, cloud +#' coverage). +#' @param product_type Type of the CDSE Product (e.g., S2MSI2A) +#' @param ... Additional query parameters. +#' @param source Data source. +#' @param collection Open Search collection endpoint. +#' @param start_date Start date. +#' @param end_date End date. +#' @param bbox Bounding box of the area from data must be from +#' @param paginate A Boolean flag that indicates whether pagination +#' should be used. +#' @param limit Limit of content to be retrieved per page. Use `paginate` +#' to manage if multiple pages should be requested. +#' @return List of features compatible with. +#' `rstac` (`rstac::doc_items`). +.opensearch_cdse_client <- function(product_type, + source, collection, + start_date, end_date, + bbox, + paginate = TRUE, + limit = 1000, ...) { + # CDSE Open Search configurations + cdse_opensearch_base_url <- .conf( + "sources", + source, + "url" + ) + cdse_opensearch_max_items <- limit + cdse_opensearch_endpoint <- "search.json" + # Create the Open Search endpoint for the collection + # Selected by user + collection_url <- paste( + cdse_opensearch_base_url, + collection, + cdse_opensearch_endpoint, + sep = "/" + ) + # Define features to save content from Open Search + features_result <- c() + # Define variables to support the pagination in the Open Search + current_page <- 1 + is_to_fetch_more <- TRUE + # Prepare bounding box in the format required by Open Search + if (!is.null(bbox)) { + bbox <- paste(bbox, collapse = ",") + } + # Prepare query object + query <- list( + startDate = start_date, + completionDate = end_date, + maxRecords = cdse_opensearch_max_items, + page = current_page, + box = bbox, + productType = product_type, + ... + ) + query <- purrr::discard(query, is.null) + # Get items from Open Search (with pagination) + while(is_to_fetch_more) { + # Get raw content from Open Search API + response <- httr::GET(url = collection_url, query = query) + .check_int_parameter(httr::status_code(response), + min = 200, + max = 200, + msg = "Failed to fetch data") + # Extract data from the response + page_data <- httr::content(response, "parsed") + # Extract features from response data + features <- page_data[["features"]] + features <- .opensearch_as_stac_item(features, product_type) + # Save results + features_result <- c(features_result, features) + # Check if is required to fetch more + links <- page_data[["properties"]][["links"]] + is_to_fetch_more <- purrr::map_lgl(links, function(x) { + x[["rel"]] == "next" + }) + is_to_fetch_more <- paginate && any(is_to_fetch_more) + # Prepare next page fetch + current_page <- current_page + as.numeric(is_to_fetch_more) + # Update query + query[["page"]] <- current_page + } + .opensearch_as_stac_items(features_result) +} + +#' @title Extract `tile` from Open Search Items. +#' @keywords internal +#' @noRd +#' +#' @description +#' This function prepares an Open Search item to act as an STAC Item, +#' compatible with the `rstac` package. This is required to avoid changes in +#' other parts of the `sits` validation structure and to use features +#' from `rstac`. +#' @param items List of features compatible with `rstac` (`rstac::doc_items`). +#' @return List of tiles. +.opensearch_cdse_extract_tile <- function(items) { + UseMethod(".opensearch_cdse_extract_tile") +} + +#' @keywords internal +#' @noRd +.opensearch_cdse_extract_tile.S2MSI2A <- function(items) { + items_titles <- rstac::items_reap(items, field = c("properties", "title")) + purrr::map(items_titles, function(item_title) { + tile_name <- stringr::str_split(item_title, "_")[[1]][6] + tile_name <- stringr::str_replace(tile_name, "T", "") + tile_name + }) +} + +#' @keywords internal +#' @noRd +.opensearch_cdse_extract_tile.RTC <- function(items) { + "NoTilingSystem" +} + +#' @title Search data using CDSE Open Search. +#' @keywords internal +#' @noRd +#' +#' @description +#' This auxiliary function is used to query the CDSE Open Search API. This is +#' a specialization of the `.opensearch_cdse_client` to handle the +#' requirements of each CDSE data product. +#' @param product_type Type of the CDSE Product (e.g., S2MSI2A) +#' @param ... Additional query parameters. +#' @param source Data source. +#' @param collection Open Search collection endpoint. +#' @param start_date Start date. +#' @param end_date End date. +#' @param bbox Bounding box of the area from data must be from +#' @param paginate A Boolean flag that indicates whether pagination +#' should be used. +#' @param limit Limit of content to be retrieved per page. Use `paginate` +#' to manage if multiple pages should be requested. +#' @return List of features compatible with +#' `rstac` (`rstac::doc_items`). +.opensearch_cdse_search <- function(product_type, + source, + collection, + start_date, + end_date, + bbox, + paginate = TRUE, + limit = 1000, ...) { + UseMethod(".opensearch_cdse_search") +} + +#' @keywords internal +#' @noRd +.opensearch_cdse_search.S2MSI2A <- function(product_type, ..., + source, + collection, + start_date, + end_date, + bbox, + paginate = TRUE, + limit = 1000) { + .opensearch_cdse_client( + product_type, + source, + collection, + start_date, + end_date, + bbox, + paginate, + limit, + status = "ONLINE" + ) +} + +#' @keywords internal +#' @noRd +.opensearch_cdse_search.RTC <- function(product_type, ..., + source, + collection, + start_date, + end_date, + bbox, + paginate = TRUE, + limit = 1000, + orbit = "descending") { + # Checks - Orbit + orbits <- .conf("sources", source, "collections", collection, "orbits") + .check_chr_within(orbit, orbits, msg = "Invalid `orbit` value") + # Search! + .opensearch_cdse_client( + product_type, + source, + collection, + start_date, + end_date, + bbox, + paginate, + limit, + status = "ONLINE", + orbitDirection = stringr::str_to_upper(orbit) + ) +} + +# ---- source api ---- +#' @title Test access to STAC collection +#' @keywords internal +#' @noRd +#' +#' @description +#' These functions provide an API to handle/retrieve data from source's +#' collections. +#' +#' @param source Data source. +#' @param collection Image collection. +#' @param bands Band names. +#' @param ... Other parameters to be passed for specific types. +#' @param start_date Start date. +#' @param end_date End date. +#' @param dry_run TRUE/FALSE. +#' @return Called for side effects +#' @export +.source_collection_access_test.cdse_cube <- function(source, collection, + bands, ..., + start_date = NULL, + end_date = NULL, + dry_run = FALSE) { + # check if `aws.s3` is installed + .check_require_packages("aws.s3") + # as CDSE STAC returns many types of items in the same collection, + # it is required to filter the content by a specific type. + item_type <- .cdse_item_type(source, collection) + # extract collection endpoint + collection_endpoint <- .conf( + "sources", + source, + "collections", + collection, + "collection_name" + ) + # query Open Search + items <- .try({ + .opensearch_cdse_search( + product_type = item_type, + source = source, + collection = collection_endpoint, + start_date = start_date, + end_date = end_date, + bbox = NULL, + paginate = FALSE, + limit = 1 + ) + }, .default = NULL) + # Check items + .check_stac_items(items) + # Test bands and accessibility + items <- .source_items_bands_select( + source = source, + items = items, + bands = bands[[1]], + collection = collection, ... + ) + href <- .source_item_get_hrefs( + source = source, + item = items$feature[[1]], + collection = collection, ... + ) + # assert that token and/or href is valid + if (dry_run) { + rast <- .try({.raster_open_rast(href)}, + default = NULL + ) + .check_null_parameter(rast) + } + return(invisible(source)) +} + +#' @title Transform an items object in a CDSE cube +#' @keywords internal +#' @noRd +#' @description \code{.source_items_new()} this function is called to create +#' an items object. In case of Web services, this function is responsible for +#' making the Web requests to the server. +#' @param source Name of the STAC provider. +#' @param ... Other parameters to be passed for specific types. +#' @param collection Collection to be searched in the data source. +#' @param stac_query Query that follows the STAC protocol +#' @param tiles Selected tiles. +#' @param orbit Selected orbit. +#' @param multicores Number of workers used to create the CDSE cube. +#' @param platform Satellite platform (not supported). +#' @return An object referring the images of a sits cube. +#' +#' @export +.source_items_new.cdse_cube <- function(source, ..., + collection, + stac_query, + tiles = NULL, + orbit = "descending", + multicores = 2L) { + # set caller to show in errors + .check_set_caller(".source_items_new_cdse_cube") + # check parameters + .check_int_parameter(multicores, min = 1, max = 2048) + # define the maximum number of records per request + cdse_query_limit <- 1000 + # as CDSE STAC returns many types of items in the same collection, + # it is required to filter the content by a specific type. + item_type <- .cdse_item_type(source, collection) + # extract collection endpoint + collection_endpoint <- .conf( + "sources", + source, + "collections", + collection, + "collection_name" + ) + # extract query parameters from STAC Query + query_bbox <- .stac_cdse_intersects_as_bbox(stac_query) + query_date <- .stac_cdse_datetime_as_dates(stac_query) + # CDSE does not support tiles - convert to ROI + # Currently, `sits` only supports Sentinel products. In the future, with + # other products, this must be revised. + if (!is.null(tiles)) { + roi <- .s2_mgrs_to_roi(tiles) + query_bbox$bbox <- c(roi[["lon_min"]], + roi[["lat_min"]], + roi[["lon_max"]], + roi[["lat_max"]] + ) + } + .check_null(query_bbox$bbox) + # Currently CDSE STAC filters are limited. As there is no possibility of + # using specific selections, sometimes using the first item returned from + # STAC can be a problem (e.g., Auxiliary products). To avoid this problem, + # we use the Open Search API. + items <- .opensearch_cdse_search( + product_type = item_type, + source = source, + collection = collection_endpoint, + start_date = query_date$start_date, + end_date = query_date$end_date, + bbox = query_bbox$bbox, + limit = cdse_query_limit, + orbit = orbit + ) + # Validate results + .check_length(items[["features"]], len_min = 1) + # Done! + items +} + +#' @title Select bands from a STAC item +#' @keywords internal +#' @noRd +#' +#' @param source Data source +#' @param ... Additional parameters. +#' @param items STAC items +#' @param bands Bands to be selected in the collection. +#' @param collection Image collection +#' @param multicores Number of workers used to extract metadata from CDSE S3. +#' @return List of STAC items +#' @export +.source_items_bands_select.cdse_cube <- function(source, ..., + items, bands, + collection, multicores) { + # CDSE does not provide files in the `assets` property. So, it is + # required to fix this using content from CDSE S3 API. + items <- .stac_cdse_fix_items(source, items, bands, collection, multicores) + # With the correct metadata, it is possible to use the base workflow. + .source_items_bands_select.stac_cube( + source, + items, + bands, + collection, + ... + ) +} + +#' @keywords internal +#' @noRd +#' @export +.source_items_tile.cdse_cube <- function(source, + ..., + items, + collection = NULL) { + rstac::items_reap(items, field = c("properties", "tile")) +} + +#' @keywords internal +#' @noRd +#' @export +.source_item_get_date.cdse_cube <- function(source, + item, + ..., + collection = NULL) { + as.Date(rstac::items_reap(item, field = c("properties", "startDate"))) +} + +#' @keywords internal +#' @noRd +#' @export +.source_item_get_cloud_cover.cdse_cube <- function(source, ..., + item, + collection = NULL) { + rstac::items_reap(item, field = c("properties", "cloudCover")) +} + +#' @keywords internal +#' @noRd +#' @export +`.source_items_tile.cdse_cube_sentinel-1-rtc` <- function(source, + items, ..., + collection = NULL) { + rep("NoTilingSystem", rstac::items_length(items)) +} + +#' @keywords internal +#' @noRd +#' @export +`.source_tile_get_bbox.cdse_cube_sentinel-1-rtc` <- + function(source, file_info, ..., collection = NULL) { + # pre-condition + .check_num(nrow(file_info), min = 1, msg = "invalid 'file_info' value") + + # get bbox based on file_info + xmin <- min(file_info[["xmin"]]) + ymin <- min(file_info[["ymin"]]) + xmax <- max(file_info[["xmax"]]) + ymax <- max(file_info[["ymax"]]) + + # post-condition + .check_that(xmin < xmax && ymin < ymax) + # create a bbox + bbox <- c(xmin = xmin, ymin = ymin, xmax = xmax, ymax = ymax) + return(bbox) +} diff --git a/R/sits_cube.R b/R/sits_cube.R index 4cb0b46f8..e314cbde3 100755 --- a/R/sits_cube.R +++ b/R/sits_cube.R @@ -307,7 +307,8 @@ sits_cube.sar_cube <- function(source, end_date = end_date, platform = platform, progress = progress, - orbit = orbit + orbit = orbit, + ... ) } #' @rdname sits_cube diff --git a/tests/testthat/test-cube.R b/tests/testthat/test-cube.R index ea00230cb..6b836aa96 100644 --- a/tests/testthat/test-cube.R +++ b/tests/testthat/test-cube.R @@ -4,11 +4,18 @@ test_that("List collections", { expect_true(grepl("DEAFRICA", col)) expect_true(grepl("LANDSAT", col)) expect_true(grepl("BDC", col)) + expect_true(grepl("CDSE", col)) col_bdc <- capture_output(sits_list_collections(source = "BDC")) expect_true(grepl("CBERS-WFI-16D", col_bdc)) expect_true(grepl("CBERS-WFI-8D", col_bdc)) }) test_that("api_source", { + res_s2_b2 <- .source_bands_resolution( + source = "CDSE", + collection = "SENTINEL-2-L2A", + bands = "B02" + ) + expect_equal(res_s2_b2[["B02"]], 10) res_s2_b8a <- .source_bands_resolution( source = "MPC", collection = "SENTINEL-2-L2A", From d1a39f939f71ec34f0ebecd9bd2a7d6eebafd61b Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Mon, 22 Apr 2024 20:42:47 -0300 Subject: [PATCH 04/11] fix sentinel-1-rtc plot --- R/api_plot_raster.R | 3 ++- R/sits_plot.R | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/R/api_plot_raster.R b/R/api_plot_raster.R index 1f752162b..cbeb935b6 100644 --- a/R/api_plot_raster.R +++ b/R/api_plot_raster.R @@ -78,7 +78,8 @@ n = n_colors, palette = palette, title = band, - midpoint = NA + midpoint = NA, + style.args = list(na.rm = TRUE) ) + tmap::tm_graticules( labels.size = as.numeric(.conf("tmap", "graticules_labels_size")) diff --git a/R/sits_plot.R b/R/sits_plot.R index 3539dced1..b059da976 100644 --- a/R/sits_plot.R +++ b/R/sits_plot.R @@ -361,7 +361,7 @@ plot.raster_cube <- function(x, ..., style = "cont", n_colors = 10, rev = FALSE, - scale = 0.8) { + scale = 1) { .check_set_caller(".plot_raster_cube") # check for color_palette parameter (sits 1.4.1) dots <- list(...) From 194a84bb6432ff181a545395771b6ca743763ba7 Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Mon, 22 Apr 2024 22:32:44 -0300 Subject: [PATCH 05/11] organize sources config --- R/api_conf.R | 2 +- inst/extdata/{ => sources}/config_source_aws.yml | 0 inst/extdata/{ => sources}/config_source_bdc.yml | 0 inst/extdata/{ => sources}/config_source_cdse.yml | 0 inst/extdata/{ => sources}/config_source_deafrica.yml | 0 inst/extdata/{ => sources}/config_source_hls.yml | 0 inst/extdata/{ => sources}/config_source_mpc.yml | 0 inst/extdata/{ => sources}/config_source_sdc.yml | 0 inst/extdata/{ => sources}/config_source_usgs.yml | 0 9 files changed, 1 insertion(+), 1 deletion(-) rename inst/extdata/{ => sources}/config_source_aws.yml (100%) rename inst/extdata/{ => sources}/config_source_bdc.yml (100%) rename inst/extdata/{ => sources}/config_source_cdse.yml (100%) rename inst/extdata/{ => sources}/config_source_deafrica.yml (100%) rename inst/extdata/{ => sources}/config_source_hls.yml (100%) rename inst/extdata/{ => sources}/config_source_mpc.yml (100%) rename inst/extdata/{ => sources}/config_source_sdc.yml (100%) rename inst/extdata/{ => sources}/config_source_usgs.yml (100%) diff --git a/R/api_conf.R b/R/api_conf.R index 07200e7e8..021f126b8 100644 --- a/R/api_conf.R +++ b/R/api_conf.R @@ -153,7 +153,7 @@ .conf_sources_files <- function() { .check_set_caller(".conf_sources_files") # list the source files configurations - package_files <- system.file("extdata", package = "sits") + package_files <- system.file("extdata", "sources", package = "sits") yml_files <- list.files( path = package_files, pattern = "config_source_*", diff --git a/inst/extdata/config_source_aws.yml b/inst/extdata/sources/config_source_aws.yml similarity index 100% rename from inst/extdata/config_source_aws.yml rename to inst/extdata/sources/config_source_aws.yml diff --git a/inst/extdata/config_source_bdc.yml b/inst/extdata/sources/config_source_bdc.yml similarity index 100% rename from inst/extdata/config_source_bdc.yml rename to inst/extdata/sources/config_source_bdc.yml diff --git a/inst/extdata/config_source_cdse.yml b/inst/extdata/sources/config_source_cdse.yml similarity index 100% rename from inst/extdata/config_source_cdse.yml rename to inst/extdata/sources/config_source_cdse.yml diff --git a/inst/extdata/config_source_deafrica.yml b/inst/extdata/sources/config_source_deafrica.yml similarity index 100% rename from inst/extdata/config_source_deafrica.yml rename to inst/extdata/sources/config_source_deafrica.yml diff --git a/inst/extdata/config_source_hls.yml b/inst/extdata/sources/config_source_hls.yml similarity index 100% rename from inst/extdata/config_source_hls.yml rename to inst/extdata/sources/config_source_hls.yml diff --git a/inst/extdata/config_source_mpc.yml b/inst/extdata/sources/config_source_mpc.yml similarity index 100% rename from inst/extdata/config_source_mpc.yml rename to inst/extdata/sources/config_source_mpc.yml diff --git a/inst/extdata/config_source_sdc.yml b/inst/extdata/sources/config_source_sdc.yml similarity index 100% rename from inst/extdata/config_source_sdc.yml rename to inst/extdata/sources/config_source_sdc.yml diff --git a/inst/extdata/config_source_usgs.yml b/inst/extdata/sources/config_source_usgs.yml similarity index 100% rename from inst/extdata/config_source_usgs.yml rename to inst/extdata/sources/config_source_usgs.yml From ec6c24269e62e7b60b19f4ddc8eed17b2d2e79ab Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Mon, 22 Apr 2024 22:33:13 -0300 Subject: [PATCH 06/11] update plot docs --- man/plot.raster_cube.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/plot.raster_cube.Rd b/man/plot.raster_cube.Rd index 212ecad0e..b9225ec5d 100644 --- a/man/plot.raster_cube.Rd +++ b/man/plot.raster_cube.Rd @@ -17,7 +17,7 @@ style = "cont", n_colors = 10, rev = FALSE, - scale = 0.8 + scale = 1 ) } \arguments{ From b7d1ef4cce4a356c854e95b50cee529f0e26c6f3 Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Tue, 23 Apr 2024 18:19:55 -0300 Subject: [PATCH 07/11] include tiles filter for rtc data from cdse --- R/api_source_cdse.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/R/api_source_cdse.R b/R/api_source_cdse.R index bc9e93adc..a6fafa534 100644 --- a/R/api_source_cdse.R +++ b/R/api_source_cdse.R @@ -612,6 +612,16 @@ rep("NoTilingSystem", rstac::items_length(items)) } +#' @keywords internal +#' @noRd +#' @export +`.source_filter_tiles.cdse_cube_sentinel-1-rtc` <- function(source, + collection, + cube, + tiles) { + return(cube) +} + #' @keywords internal #' @noRd #' @export From dddb70b2bfd9d09df3452de43af53ce788d7b001 Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Tue, 23 Apr 2024 18:21:03 -0300 Subject: [PATCH 08/11] fix mgrs tiles filter --- R/api_regularize.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/api_regularize.R b/R/api_regularize.R index 3e26b407b..f5aed1cc8 100644 --- a/R/api_regularize.R +++ b/R/api_regularize.R @@ -201,6 +201,9 @@ dplyr::group_map(~{ # prepare a sf object representing the bbox of each image in file_info cube_crs <- dplyr::filter(cube, .data[["crs"]] == .x$crs) + if (nrow(cube_crs) == 0) { + cube_crs <- cube + } fi_bbox <- .bbox_as_sf(.bbox( x = .fi(cube_crs), default_crs = .crs(cube_crs), From fc3de2b207dae3f59b1c16f0a81747a26e1ed87d Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Tue, 23 Apr 2024 18:21:28 -0300 Subject: [PATCH 09/11] add environment api to enable cdse tests --- DESCRIPTION | 1 + NAMESPACE | 1 + R/api_environment.R | 121 +++++++++++++++++++++++++++++ tests/testthat/test-cube-cdse.R | 123 ++++++++++++++++++++++++++++++ tests/testthat/test-environment.R | 27 +++++++ 5 files changed, 273 insertions(+) create mode 100644 R/api_environment.R create mode 100644 tests/testthat/test-cube-cdse.R create mode 100644 tests/testthat/test-environment.R diff --git a/DESCRIPTION b/DESCRIPTION index 812110063..5c502232d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -131,6 +131,7 @@ Collate: 'api_data.R' 'api_debug.R' 'api_download.R' + 'api_environment.R' 'api_factory.R' 'api_file_info.R' 'api_file.R' diff --git a/NAMESPACE b/NAMESPACE index 6b8de47d5..926001c04 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -131,6 +131,7 @@ S3method(.source_collection_access_test,mpc_cube) S3method(.source_collection_access_test,stac_cube) S3method(.source_collection_access_test,usgs_cube) S3method(.source_cube,stac_cube) +S3method(.source_filter_tiles,"cdse_cube_sentinel-1-rtc") S3method(.source_filter_tiles,"mpc_cube_sentinel-1-grd") S3method(.source_filter_tiles,stac_cube) S3method(.source_item_get_bands,stac_cube) diff --git a/R/api_environment.R b/R/api_environment.R new file mode 100644 index 000000000..95ace0b60 --- /dev/null +++ b/R/api_environment.R @@ -0,0 +1,121 @@ + +# ---- Environment operations ---- +#' @title Function to patch environment variables (Developer only). +#' @keywords internal +#' @noRd +#' +#' @description +#' This function patches environment variables, swapping them from a `source` +#' to a `target` variable. You can rollback the swap operation using the +#' `.environment_rollback.` +#' +#' @note +#' This function is suitable only for internal `sits` tests and should not be +#' used for any other purpose. +#' @param env_config List with the configuration of the environment. +#' @return Called for side effects. +.environment_patch <- function(env_config) { + env_prefix <- env_config[["name"]] + env_variables <- env_config[["variables"]] + + purrr::map(1:length(env_variables), function(var_idx) { + var_source <- names(env_variables)[[var_idx]] + var_target <- unname(env_variables)[[var_idx]] + # Get current value of the target variable + var_target_value <- Sys.getenv(var_target) + # Save current value of the target variable in the "swap area" + var_target_swap <- paste(env_prefix, var_target, sep = "_SWAP_") + var_target_swap_value <- list(tmp = var_target_value) + var_target_swap_value <- stats::setNames( + var_target_swap_value, + var_target_swap + ) + # Save variable + do.call(Sys.setenv, var_target_swap_value) + # Get the new value of the target variable + var_source_value <- Sys.getenv(var_source) + # Save new value in the target variable + var_target_new_value <- list(tmp = var_source_value) + var_target_new_value <- stats::setNames( + var_target_new_value, + var_target + ) + # Save variable + do.call(Sys.setenv, var_target_new_value) + }) + return(invisible(NULL)) +} + +#' @title Function to rollback patch in environment variables (Developer only). +#' @keywords internal +#' @noRd +#' +#' @description +#' This function rollback patches in environment variables created with the +#' function `.environment_patch`. +#' @note +#' This function is suitable only for internal `sits` tests and should not be +#' used for any other purpose. +#' @param env_config List with the configuration of the environment. +#' @return Called for side effects. +.environment_rollback <- function(env_config) { + env_prefix <- env_config[["name"]] + env_variables <- env_config[["variables"]] + + purrr::map(1:length(env_variables), function(var_idx) { + var_source <- names(env_variables)[[var_idx]] + var_target <- unname(env_variables)[[var_idx]] + # Get current value of the target variable + var_target_value <- Sys.getenv(var_target) + # Save current value in the source variable + var_source_new_value <- list(tmp = var_target_value) + var_source_new_value <- stats::setNames( + var_source_new_value, + var_source + ) + do.call(Sys.setenv, var_source_new_value) + # Get current value of the target variable in the "swap area" + var_target_swap <- paste(env_prefix, var_target, sep = "_SWAP_") + var_target_swap_value <- Sys.getenv(var_target_swap) + # Prepare current target + var_target_swap_value <- list(tmp = var_target_swap_value) + var_target_swap_value <- stats::setNames( + var_target_swap_value, + var_target + ) + do.call(Sys.setenv, var_target_swap_value) + }) + return(invisible(NULL)) +} + +# ---- Environment configurations ---- +#' @title Function to create patch configuration for the CDSE source. +#' @keywords internal +#' @noRd +#' +#' @description +#' This function creates a configuration for the `patch` and `rollback` +#' specialized for the CDSE requirements. +#' @note +#' This function is suitable only for internal `sits` tests and should not be +#' used for any other purpose. +#' @return List with the configuration of the CDSE environment. +.environment_cdse <- function() { + # Define environment name. This name is used as a prefix for the + # "swap area" which is used to keep values saved + env_name <- "CDSE" + # Create the environment variables + env_variables <- list( + "CDSE_ACCESS_KEY_ID" = "AWS_ACCESS_KEY_ID", + "CDSE_SECRET_ACCESS_KEY" = "AWS_SECRET_ACCESS_KEY", + "CDSE_S3_ENDPOINT" = "AWS_S3_ENDPOINT", + "CDSE_VIRTUAL_HOSTING" = "AWS_VIRTUAL_HOSTING" + ) + # Create a base environment definition + env_definition <- + list(name = env_name, variables = env_variables) + # Define a class, based on the name + class(env_definition) <- c(env_name, "list") + # Done! + env_definition +} diff --git a/tests/testthat/test-cube-cdse.R b/tests/testthat/test-cube-cdse.R new file mode 100644 index 000000000..09a1e2155 --- /dev/null +++ b/tests/testthat/test-cube-cdse.R @@ -0,0 +1,123 @@ +test_that("Creating S2 cubes from CDSE with ROI", { + # Configure environment + cdse_env_config <- .environment_cdse() + # Patch environment variables + .environment_patch(cdse_env_config) + # Test + roi <- c( + lon_min = -48.28579, lat_min = -16.05026, + lon_max = -47.30839, lat_max = -15.50026 + ) + s2_cube_cdse <- .try( + { + sits_cube( + source = "CDSE", + collection = "SENTINEL-2-L2A", + roi = roi, + bands = c("B05", "CLOUD"), + start_date = as.Date("2018-07-18"), + end_date = as.Date("2018-08-23"), + progress = FALSE, + multicores = 1L + ) + }, + .default = NULL + ) + testthat::skip_if(purrr::is_null(s2_cube_cdse), "CDSE is not accessible") + expect_true(all(sits_bands(s2_cube_cdse) %in% c("B05", "CLOUD"))) + expect_equal(nrow(s2_cube_cdse), 3) + bbox_cube <- sits_bbox(s2_cube_cdse, as_crs = "EPSG:4326") + bbox_cube_1 <- sits_bbox(.tile(s2_cube_cdse), as_crs = "EPSG:4326") + expect_true(bbox_cube["xmax"] >= bbox_cube_1["xmax"]) + expect_true(bbox_cube["ymax"] >= bbox_cube_1["ymax"]) + r_obj <- .raster_open_rast(s2_cube_cdse$file_info[[1]]$path[1]) + cube_nrows <- .tile_nrows(s2_cube_cdse) + expect_true(.raster_nrows(r_obj) == cube_nrows) + # Rollback environment changes + .environment_rollback(cdse_env_config) +}) +test_that("Creating S2 cubes from CDSE with tiles", { + # Configure environment + cdse_env_config <- .environment_cdse() + # Patch environment variables + .environment_patch(cdse_env_config) + # Test + s2_cube <- .try( + { + sits_cube( + source = "CDSE", + collection = "SENTINEL-2-L2A", + tiles = "20LKP", + bands = c("B05", "CLOUD"), + start_date = as.Date("2018-07-18"), + end_date = as.Date("2018-08-23"), + progress = FALSE, + multicores = 1L + ) + }, + .default = NULL + ) + expect_true(all(sits_bands(s2_cube) %in% c("B05", "CLOUD"))) + r <- .raster_open_rast(.tile_path(s2_cube)) + expect_equal(s2_cube$xmax[[1]], .raster_xmax(r), tolerance = 1) + expect_equal(s2_cube$xmin[[1]], .raster_xmin(r), tolerance = 1) + r_obj <- .raster_open_rast(s2_cube$file_info[[1]]$path[1]) + cube_nrows <- .tile_nrows(s2_cube) + expect_true(.raster_nrows(r_obj) == cube_nrows) + # Rollback environment changes + .environment_rollback(cdse_env_config) +}) + +test_that("Creating Sentinel-1 RTC cubes from CDSE", { + # Configure environment + cdse_env_config <- .environment_cdse() + # Patch environment variables + .environment_patch(cdse_env_config) + # Test + cube_s1_rtc <- sits_cube( + source = "CDSE", + collection = "SENTINEL-1-RTC", + bands = c("VV"), + orbit = "descending", + tiles = c("36NWH"), + start_date = "2021-07-01", + end_date = "2021-09-30", + multicores = 1L + ) + bbox <- sits_bbox(cube_s1_rtc[1,]) + expect_true(grepl("4326", bbox[["crs"]])) + expect_equal(32, bbox[["xmin"]]) + expect_equal(34, bbox[["xmax"]]) + expect_equal(nrow(cube_s1_rtc$file_info[[1]]), 68) + + output_dir <- paste0(tempdir(), "/s1rtcreg") + if (!dir.exists(output_dir)) { + dir.create(output_dir) + } + + cube_s1_rtc_reg <- sits_regularize( + cube = cube_s1_rtc, + period = "P1M", + res = 240, + tiles = c("36NXG", "36NVG"), + multicores = 1, + output_dir = output_dir, + progress = TRUE + ) + expect_equal(length(sits_timeline(cube_s1_rtc_reg)), 3) + expect_true(all(c("36NXG", "36NVG") %in% + cube_s1_rtc_reg$tile)) + expect_true("EPSG:32636" %in% cube_s1_rtc_reg$crs) + + bbox <- sits_bbox(cube_s1_rtc_reg, as_crs = "EPSG:4326") + roi_cube_s1 <- sits_mgrs_to_roi(c("36NXG", "36NVG")) + + expect_equal(bbox[["xmin"]], roi_cube_s1[["lon_min"]], tolerance = 0.01) + expect_equal(bbox[["xmax"]], roi_cube_s1[["lon_max"]], tolerance = 0.03) + expect_equal(bbox[["ymin"]], roi_cube_s1[["lat_min"]], tolerance = 0.25) + expect_equal(bbox[["ymax"]], roi_cube_s1[["lat_max"]], tolerance = 0.01) + expect_true(all(c("VV") %in% sits_bands(cube_s1_rtc_reg))) + + # Rollback environment changes + .environment_rollback(cdse_env_config) +}) diff --git a/tests/testthat/test-environment.R b/tests/testthat/test-environment.R new file mode 100644 index 000000000..a3ca4f1b1 --- /dev/null +++ b/tests/testthat/test-environment.R @@ -0,0 +1,27 @@ +test_that("Test environment variables swap", { + # Setup - Environment configuration + env_config <- list( + name = "SITS_TEST", + variables = list( + "A" = "B", + "C" = "D" + ) + ) + # Setup - Env variables + Sys.setenv("A" = 123) + Sys.setenv("B" = 321) + Sys.setenv("C" = "ABC") + Sys.setenv("D" = "CBA") + # Test - Swapped variables + .environment_patch(env_config) + + expect_equal(Sys.getenv("B"), "123") + expect_equal(Sys.getenv("D"), "ABC") + expect_equal(Sys.getenv("SITS_TEST_SWAP_B"), "321") + expect_equal(Sys.getenv("SITS_TEST_SWAP_D"), "CBA") + # Test - Rollback variables + .environment_rollback(env_config) + + expect_equal(Sys.getenv("B"), "321") + expect_equal(Sys.getenv("D"), "CBA") +}) From 3a0f8e97b247be37fe48c4297c7707fbf282abaa Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Tue, 23 Apr 2024 21:43:45 -0300 Subject: [PATCH 10/11] add cdse examples --- R/api_source_cdse.R | 2 +- R/sits_cube.R | 24 ++++++++++++++++++++++++ man/sits_cube.Rd | 24 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/R/api_source_cdse.R b/R/api_source_cdse.R index a6fafa534..1da272d2c 100644 --- a/R/api_source_cdse.R +++ b/R/api_source_cdse.R @@ -560,7 +560,7 @@ #' @export .source_items_bands_select.cdse_cube <- function(source, ..., items, bands, - collection, multicores) { + collection, multicores = 2L) { # CDSE does not provide files in the `assets` property. So, it is # required to fix this using content from CDSE S3 API. items <- .stac_cdse_fix_items(source, items, bands, collection, multicores) diff --git a/R/sits_cube.R b/R/sits_cube.R index e314cbde3..92224dde2 100755 --- a/R/sits_cube.R +++ b/R/sits_cube.R @@ -214,6 +214,30 @@ #' start_date = "2019-01-01", #' end_date = "2019-10-28" #' ) +#' # --- Access to CDSE open data Sentinel 2/2A level 2 collection +#' # It is recommended that `multicores` be used to accelerate the process. +#' s2_cube <- sits_cube( +#' source = "CDSE", +#' collection = "SENTINEL-2-L2A", +#' tiles = c("20LKP"), +#' bands = c("B04", "B08", "B11"), +#' start_date = "2018-07-18", +#' end_date = "2019-07-23" +#' ) +#' +#' ## -- Sentinel-1 SAR from CDSE +#' roi <- c("lon_min" = 33.546, "lon_max" = 34.999, +#' "lat_min" = 1.427, "lat_max" = 3.726) +#' s1_cube_open <- sits_cube( +#' source = "CDSE", +#' collection = "SENTINEL-1-RTC", +#' bands = c("VV", "VH"), +#' orbit = "descending", +#' roi = roi_sar, +#' start_date = "2020-01-01", +#' end_date = "2020-06-10" +#' ) +#' #' # --- Access to AWS open data Sentinel 2/2A level 2 collection #' s2_cube <- sits_cube( #' source = "AWS", diff --git a/man/sits_cube.Rd b/man/sits_cube.Rd index 9085a0348..7c6351cd2 100644 --- a/man/sits_cube.Rd +++ b/man/sits_cube.Rd @@ -290,6 +290,30 @@ if (sits_run_examples()) { start_date = "2019-01-01", end_date = "2019-10-28" ) + # --- Access to CDSE open data Sentinel 2/2A level 2 collection + # It is recommended that `multicores` be used to accelerate the process. + s2_cube <- sits_cube( + source = "CDSE", + collection = "SENTINEL-2-L2A", + tiles = c("20LKP"), + bands = c("B04", "B08", "B11"), + start_date = "2018-07-18", + end_date = "2019-07-23" + ) + + ## -- Sentinel-1 SAR from CDSE + roi <- c("lon_min" = 33.546, "lon_max" = 34.999, + "lat_min" = 1.427, "lat_max" = 3.726) + s1_cube_open <- sits_cube( + source = "CDSE", + collection = "SENTINEL-1-RTC", + bands = c("VV", "VH"), + orbit = "descending", + roi = roi_sar, + start_date = "2020-01-01", + end_date = "2020-06-10" + ) + # --- Access to AWS open data Sentinel 2/2A level 2 collection s2_cube <- sits_cube( source = "AWS", From f20f76fe370c3a5d8f5cd863b13217180b0670cc Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Tue, 23 Apr 2024 21:55:31 -0300 Subject: [PATCH 11/11] update cdse examples --- R/sits_cube.R | 6 +++--- man/sits_cube.Rd | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/sits_cube.R b/R/sits_cube.R index 92224dde2..948cb9e0d 100755 --- a/R/sits_cube.R +++ b/R/sits_cube.R @@ -222,12 +222,12 @@ #' tiles = c("20LKP"), #' bands = c("B04", "B08", "B11"), #' start_date = "2018-07-18", -#' end_date = "2019-07-23" +#' end_date = "2019-01-23" #' ) #' #' ## -- Sentinel-1 SAR from CDSE -#' roi <- c("lon_min" = 33.546, "lon_max" = 34.999, -#' "lat_min" = 1.427, "lat_max" = 3.726) +#' roi_sar <- c("lon_min" = 33.546, "lon_max" = 34.999, +#' "lat_min" = 1.427, "lat_max" = 3.726) #' s1_cube_open <- sits_cube( #' source = "CDSE", #' collection = "SENTINEL-1-RTC", diff --git a/man/sits_cube.Rd b/man/sits_cube.Rd index 7c6351cd2..f0148eb45 100644 --- a/man/sits_cube.Rd +++ b/man/sits_cube.Rd @@ -298,12 +298,12 @@ if (sits_run_examples()) { tiles = c("20LKP"), bands = c("B04", "B08", "B11"), start_date = "2018-07-18", - end_date = "2019-07-23" + end_date = "2019-01-23" ) ## -- Sentinel-1 SAR from CDSE - roi <- c("lon_min" = 33.546, "lon_max" = 34.999, - "lat_min" = 1.427, "lat_max" = 3.726) + roi_sar <- c("lon_min" = 33.546, "lon_max" = 34.999, + "lat_min" = 1.427, "lat_max" = 3.726) s1_cube_open <- sits_cube( source = "CDSE", collection = "SENTINEL-1-RTC",