From 91e12828ec4296a0ecb77dec59b448f82ac7083c Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Sun, 16 Jun 2024 17:22:05 -0300 Subject: [PATCH 1/3] add new deaustralia data products --- DESCRIPTION | 1 + NAMESPACE | 2 + R/api_source_deaustralia.R | 49 +++ .../sources/config_source_deaustralia.yml | 404 ++++++++++++++++++ 4 files changed, 456 insertions(+) create mode 100644 R/api_source_deaustralia.R create mode 100644 inst/extdata/sources/config_source_deaustralia.yml diff --git a/DESCRIPTION b/DESCRIPTION index 225ace3b9..d51a36904 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -181,6 +181,7 @@ Collate: 'api_source_bdc.R' 'api_source_cdse.R' 'api_source_deafrica.R' + 'api_source_deaustralia.R' 'api_source_hls.R' 'api_source_local.R' 'api_source_mpc.R' diff --git a/NAMESPACE b/NAMESPACE index 77420af6e..4f951510f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -168,6 +168,7 @@ 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,deaustralia_cube) S3method(.source_items_new,hls_cube) S3method(.source_items_new,sdc_cube) S3method(.source_items_new,usgs_cube) @@ -184,6 +185,7 @@ 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,deaustralia_cube) S3method(.source_items_tile,hls_cube) S3method(.source_items_tile,sdc_cube) S3method(.source_items_tile,usgs_cube) diff --git a/R/api_source_deaustralia.R b/R/api_source_deaustralia.R new file mode 100644 index 000000000..6781d8c34 --- /dev/null +++ b/R/api_source_deaustralia.R @@ -0,0 +1,49 @@ +# ---- source api ---- +#' @title Create an items object in an DEAustralia 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 (optional) +#' @param platform Satellite platform (optional). +#' @return An object referring the images of a sits cube. +#' @export +.source_items_new.deaustralia_cube <- function(source, ..., + collection, + stac_query, + tiles = NULL, + platform = NULL) { + # Convert roi to bbox + roi <- .stac_intersects_as_bbox(stac_query) + stac_query[["params"]][["intersects"]] <- NULL + stac_query[["params"]][["bbox"]] <- roi$bbox + # making the request + items_info <- rstac::post_request(q = stac_query, ...) + .check_stac_items(items_info) + # if more than 2 times items pagination are found the progress bar + # is displayed + progress <- rstac::items_matched(items_info) > + 2 * .conf("rstac_pagination_limit") + # check documentation mode + progress <- .check_documentation(progress) + + # fetching all the metadata and updating to upper case instruments + items_info <- rstac::items_fetch(items = items_info, progress = progress) + # checks if the items returned any items + .check_stac_items(items_info) + return(items_info) +} + +#' @keywords internal +#' @noRd +#' @export +.source_items_tile.deaustralia_cube <- function(source, ..., + items, + collection = NULL) { + rstac::items_reap(items, field = c("properties", "odc:region_code")) +} diff --git a/inst/extdata/sources/config_source_deaustralia.yml b/inst/extdata/sources/config_source_deaustralia.yml new file mode 100644 index 000000000..8a1f9a54e --- /dev/null +++ b/inst/extdata/sources/config_source_deaustralia.yml @@ -0,0 +1,404 @@ +# These are configuration parameters that can be set by users +# The parameters enable access to the cloud collections + +sources: + DEAUSTRALIA : + s3_class : ["deaustralia_cube", "stac_cube", "eo_cube", + "raster_cube"] + service : "STAC" + url : "https://explorer.dea.ga.gov.au/stac/" + collections : + LS5-SR : + bands : + B01 : &deaustralia_ls5_tm_30m + missing_value : -999 + minimum_value : 0 + maximum_value : 65536 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "nbart_blue" + data_type : "INT2S" + B02 : + <<: *deaustralia_ls5_tm_30m + band_name: "nbart_green" + B03 : + <<: *deaustralia_ls5_tm_30m + band_name: "nbart_red" + B04 : + <<: *deaustralia_ls5_tm_30m + band_name: "nbart_nir" + B05 : + <<: *deaustralia_ls5_tm_30m + band_name: "nbart_swir_1" + B07 : + <<: *deaustralia_ls5_tm_30m + band_name: "nbart_swir_2" + CLOUD : + bit_mask : true + band_name : "oa_fmask" + values : + 0 : "missing_data" + 1 : "Valid" + 2 : "Cloud" + 3 : "Shadow" + 4 : "Snow" + 5 : "Water" + interp_values : [0, 2, 3, 4] + resampling : "near" + resolution : 30 + data_type : "INT2U" + satellite : "LANDSAT-5" + sensor : "TM" + collection_name : "ga_ls5t_ard_3" + access_vars : + AWS_DEFAULT_REGION : "ap-southeast-2" + AWS_S3_ENDPOINT : "s3.ap-southeast-2.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 : &deaustralia_ls7_etm_30m + missing_value : -999 + minimum_value : 0 + maximum_value : 65536 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "nbart_blue" + data_type : "INT2S" + B02 : + <<: *deaustralia_ls7_etm_30m + band_name: "nbart_green" + B03 : + <<: *deaustralia_ls7_etm_30m + band_name: "nbart_red" + B04 : + <<: *deaustralia_ls7_etm_30m + band_name: "nbart_nir" + B05 : + <<: *deaustralia_ls7_etm_30m + band_name: "nbart_swir_1" + B07 : + <<: *deaustralia_ls7_etm_30m + band_name: "nbart_swir_2" + B08 : + <<: *deaustralia_ls7_etm_30m + resolution : 15 + band_name: "nbart_panchromatic" + CLOUD : + bit_mask : true + band_name : "oa_fmask" + values : + 0 : "missing_data" + 1 : "Valid" + 2 : "Cloud" + 3 : "Shadow" + 4 : "Snow" + 5 : "Water" + interp_values : [0, 2, 3, 4] + resampling : "near" + resolution : 30 + data_type : "INT2U" + satellite : "LANDSAT-7" + sensor : "ETM" + collection_name : "ga_ls7e_ard_3" + access_vars : + AWS_DEFAULT_REGION : "ap-southeast-2" + AWS_S3_ENDPOINT : "s3.ap-southeast-2.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 : + bands : + B01 : &deaustralia_ls8_oli_30m + missing_value : -999 + minimum_value : 0 + maximum_value : 65536 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "nbart_coastal_aerosol" + data_type : "INT2U" + B02 : + <<: *deaustralia_ls8_oli_30m + band_name : "nbart_blue" + B03 : + <<: *deaustralia_ls8_oli_30m + band_name : "nbart_green" + B04 : + <<: *deaustralia_ls8_oli_30m + band_name : "nbart_red" + B05 : + <<: *deaustralia_ls8_oli_30m + band_name : "nbart_nir" + B06 : + <<: *deaustralia_ls8_oli_30m + band_name : "nbart_swir_1" + B07 : + <<: *deaustralia_ls8_oli_30m + band_name : "nbart_swir_2" + B08 : + <<: *deaustralia_ls8_oli_30m + resolution : 15 + band_name : "nbart_panchromatic" + CLOUD : + bit_mask : true + band_name : "oa_fmask" + values : + 0 : "missing_data" + 1 : "Valid" + 2 : "Cloud" + 3 : "Shadow" + 4 : "Snow" + 5 : "Water" + interp_values : [0, 2, 3, 4] + resampling : "near" + resolution : 30 + data_type : "INT2U" + satellite : "LANDSAT-8" + sensor : "OLI-TIRS" + collection_name: "ga_ls8c_ard_3" + access_vars : + AWS_DEFAULT_REGION : "ap-southeast-2" + AWS_S3_ENDPOINT : "s3.ap-southeast-2.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data: true + open_data_token: false + metadata_search : "tile" + ext_tolerance: 0 + grid_system : "WRS-2" + LS9-SR : + bands : + B01 : &deaustralia_ls9_oli_30m + missing_value : -999 + minimum_value : 0 + maximum_value : 65536 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "nbart_coastal_aerosol" + data_type : "INT2U" + B02 : + <<: *deaustralia_ls9_oli_30m + band_name : "nbart_blue" + B03 : + <<: *deaustralia_ls9_oli_30m + band_name : "nbart_green" + B04 : + <<: *deaustralia_ls9_oli_30m + band_name : "nbart_red" + B05 : + <<: *deaustralia_ls9_oli_30m + band_name : "nbart_nir" + B06 : + <<: *deaustralia_ls9_oli_30m + band_name : "nbart_swir_1" + B07 : + <<: *deaustralia_ls9_oli_30m + band_name : "nbart_swir_2" + B08 : + <<: *deaustralia_ls9_oli_30m + resolution : 15 + band_name : "nbart_panchromatic" + CLOUD : + bit_mask : true + band_name : "oa_fmask" + values : + 0 : "missing_data" + 1 : "Valid" + 2 : "Cloud" + 3 : "Shadow" + 4 : "Snow" + 5 : "Water" + interp_values : [0, 2, 3, 4] + resampling : "near" + resolution : 30 + data_type : "INT2U" + satellite : "LANDSAT-9" + sensor : "OLI-TIRS" + collection_name: "ga_ls9c_ard_3" + access_vars : + AWS_DEFAULT_REGION: "ap-southeast-2" + AWS_S3_ENDPOINT : "s3.ap-southeast-2.amazonaws.com" + AWS_NO_SIGN_REQUEST: true + open_data: true + open_data_token: false + metadata_search : "tile" + ext_tolerance: 0 + grid_system : "WRS-2" + + SENTINEL-2A : + bands : + B01 : &deaustralia_s2a_msi_60m + missing_value : -999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 60 + band_name : "nbart_coastal_aerosol" + data_type : "INT2S" + B02 : &deaustralia_s2a_msi_10m + missing_value : -999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 10 + band_name : "nbart_blue" + data_type : "INT2S" + B03 : + <<: *deaustralia_s2a_msi_10m + band_name : "nbart_green" + B04 : + <<: *deaustralia_s2a_msi_10m + band_name : "nbart_red" + B05 : &deaustralia_s2a_msi_20m + missing_value : -999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 20 + band_name : "nbart_red_edge_1" + data_type : "INT2S" + B06 : + <<: *deaustralia_s2a_msi_20m + band_name : "nbart_red_edge_2" + B07 : + <<: *deaustralia_s2a_msi_20m + band_name : "nbart_red_edge_3" + B08 : + <<: *deaustralia_s2a_msi_10m + band_name : "nbart_nir_1" + B8A : + <<: *deaustralia_s2a_msi_20m + band_name : "nbart_nir_2" + B11 : + <<: *deaustralia_s2a_msi_20m + band_name : "nbart_swir_2" + B12 : + <<: *deaustralia_s2a_msi_20m + band_name : "nbart_swir_3" + CLOUD : + bit_mask : true + band_name : "oa_fmask" + values : + 0 : "No data" + 1 : "Valid" + 2 : "Cloud" + 3 : "Shadow" + 4 : "Snow" + 5 : "Water" + interp_values : [0, 2, 3, 4] + resampling : "near" + resolution : 10 + data_type : "INT2U" + satellite : "SENTINEL-2" + sensor : "MSI" + platforms : + SENTINEL-2A: "sentinel-2a" + collection_name: "ga_s2am_ard_3" + access_vars : + AWS_DEFAULT_REGION: "ap-southeast-2" + AWS_S3_ENDPOINT : "s3.ap-southeast-2.amazonaws.com" + AWS_NO_SIGN_REQUEST: true + open_data: true + open_data_token: false + metadata_search : "tile" + ext_tolerance: 0 + grid_system : "MGRS" + SENTINEL-2B : + bands : + B01 : &deaustralia_s2a_msi_60m + missing_value : -999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 60 + band_name : "nbart_coastal_aerosol" + data_type : "INT2U" + B02 : &deaustralia_s2a_msi_10m + missing_value : -999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 10 + band_name : "nbart_blue" + data_type : "INT2S" + B03 : + <<: *deaustralia_s2a_msi_10m + band_name : "nbart_green" + B04 : + <<: *deaustralia_s2a_msi_10m + band_name : "nbart_red" + B05 : &deaustralia_s2a_msi_20m + missing_value : -999 + minimum_value : 0 + maximum_value : 10000 + scale_factor : 0.0001 + offset_value : 0 + resolution : 20 + band_name : "nbart_red_edge_1" + data_type : "INT2S" + B06 : + <<: *deaustralia_s2a_msi_20m + band_name : "nbart_red_edge_2" + B07 : + <<: *deaustralia_s2a_msi_20m + band_name : "nbart_red_edge_3" + B08 : + <<: *deaustralia_s2a_msi_10m + band_name : "nbart_nir_1" + B8A : + <<: *deaustralia_s2a_msi_20m + band_name : "nbart_nir_2" + B11 : + <<: *deaustralia_s2a_msi_20m + band_name : "nbart_swir_2" + B12 : + <<: *deaustralia_s2a_msi_20m + band_name : "nbart_swir_3" + CLOUD : + bit_mask : true + band_name : "oa_fmask" + values : + 0 : "No data" + 1 : "Valid" + 2 : "Cloud" + 3 : "Shadow" + 4 : "Snow" + 5 : "Water" + interp_values : [0, 2, 3, 4] + resampling : "near" + resolution : 10 + data_type : "INT2U" + satellite : "SENTINEL-2B" + sensor : "MSI" + platforms : + SENTINEL-2B: "sentinel-2b" + collection_name: "ga_s2bm_ard_3" + access_vars : + AWS_DEFAULT_REGION: "ap-southeast-2" + AWS_S3_ENDPOINT : "s3.ap-southeast-2.amazonaws.com" + AWS_NO_SIGN_REQUEST: true + open_data: true + open_data_token: false + metadata_search : "tile" + ext_tolerance: 0 + grid_system : "MGRS" From 8ad6af819aea95f595bb2b1351e742d64fdc89d4 Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Tue, 18 Jun 2024 17:40:41 -0300 Subject: [PATCH 2/3] add geomedian products from deaustralia --- .../sources/config_source_deaustralia.yml | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/inst/extdata/sources/config_source_deaustralia.yml b/inst/extdata/sources/config_source_deaustralia.yml index 8a1f9a54e..f3f4ac501 100644 --- a/inst/extdata/sources/config_source_deaustralia.yml +++ b/inst/extdata/sources/config_source_deaustralia.yml @@ -402,3 +402,169 @@ sources: metadata_search : "tile" ext_tolerance: 0 grid_system : "MGRS" + + LS5-GEOMEDIAN : + bands : + B01 : &deaustralia_ls5_geomedian_band_30m + missing_value : -999 + minimum_value : 0 + maximum_value : 65536 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "blue" + data_type : "INT2S" + B02 : + <<: *deaustralia_ls5_geomedian_band_30m + band_name: "green" + B03 : + <<: *deaustralia_ls5_geomedian_band_30m + band_name: "red" + B04 : + <<: *deaustralia_ls5_geomedian_band_30m + band_name: "nir" + B05 : + <<: *deaustralia_ls5_geomedian_band_30m + band_name: "swir1" + B07 : + <<: *deaustralia_ls5_geomedian_band_30m + band_name: "swir2" + EDEV : &deaustralia_ls5_geomedian_product_30m + missing_value : -32768 + minimum_value : 0 + maximum_value : 65536 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "edev" + data_type : "FLT4S" + SDEV : + <<: *deaustralia_ls5_geomedian_product_30m + band_name: "sdev" + BCDEV : + <<: *deaustralia_ls5_geomedian_product_30m + band_name: "bcdev" + satellite : "LANDSAT-5" + sensor : "TM-GEOMEDIAN" + collection_name : "ga_ls5t_nbart_gm_cyear_3" + access_vars : + AWS_DEFAULT_REGION : "ap-southeast-2" + AWS_S3_ENDPOINT : "s3.ap-southeast-2.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-GEOMEDIAN : + bands : + B01 : &deaustralia_ls7_geomedian_band_30m + missing_value : -999 + minimum_value : 0 + maximum_value : 65536 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "blue" + data_type : "INT2S" + B02 : + <<: *deaustralia_ls7_geomedian_band_30m + band_name: "green" + B03 : + <<: *deaustralia_ls7_geomedian_band_30m + band_name: "red" + B04 : + <<: *deaustralia_ls7_geomedian_band_30m + band_name: "nir" + B05 : + <<: *deaustralia_ls7_geomedian_band_30m + band_name: "swir1" + B07 : + <<: *deaustralia_ls7_geomedian_band_30m + band_name: "swir2" + EDEV : &deaustralia_ls7_geomedian_product_30m + missing_value : -32768 + minimum_value : 0 + maximum_value : 65536 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "edev" + data_type : "FLT4S" + SDEV : + <<: *deaustralia_ls7_geomedian_product_30m + band_name: "sdev" + BCDEV : + <<: *deaustralia_ls7_geomedian_product_30m + band_name: "bcdev" + satellite : "LANDSAT-7" + sensor : "ETM-GEOMEDIAN" + collection_name : "ga_ls7e_nbart_gm_cyear_3" + access_vars : + AWS_DEFAULT_REGION : "ap-southeast-2" + AWS_S3_ENDPOINT : "s3.ap-southeast-2.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-GEOMEDIAN : + bands : + B01 : &deaustralia_ls5_geomedian_band_30m + missing_value : -999 + minimum_value : 0 + maximum_value : 65536 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "blue" + data_type : "INT2S" + B02 : + <<: *deaustralia_ls5_geomedian_band_30m + band_name: "green" + B03 : + <<: *deaustralia_ls5_geomedian_band_30m + band_name: "red" + B04 : + <<: *deaustralia_ls5_geomedian_band_30m + band_name: "nir" + B05 : + <<: *deaustralia_ls5_geomedian_band_30m + band_name: "swir1" + B07 : + <<: *deaustralia_ls5_geomedian_band_30m + band_name: "swir2" + EDEV : &deaustralia_ls5_geomedian_product_30m + missing_value : -32768 + minimum_value : 0 + maximum_value : 65536 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + resolution : 30 + band_name : "edev" + data_type : "FLT4S" + SDEV : + <<: *deaustralia_ls5_geomedian_product_30m + band_name: "sdev" + BCDEV : + <<: *deaustralia_ls5_geomedian_product_30m + band_name: "bcdev" + satellite : "LANDSAT-8" + sensor : "OLI-TIRS-GEOMEDIAN" + collection_name : "ga_ls8c_nbart_gm_cyear_3" + access_vars : + AWS_DEFAULT_REGION : "ap-southeast-2" + AWS_S3_ENDPOINT : "s3.ap-southeast-2.amazonaws.com" + AWS_NO_SIGN_REQUEST : true + open_data : true + open_data_token : false + metadata_search : "tile" + ext_tolerance : 0 + grid_system : "WRS-2" From e3347179d6954cee202f33691dc44ce19b6b4331 Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Tue, 18 Jun 2024 17:42:25 -0300 Subject: [PATCH 3/3] fix ls8 geomedian names from deaustralia --- .../sources/config_source_deaustralia.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/inst/extdata/sources/config_source_deaustralia.yml b/inst/extdata/sources/config_source_deaustralia.yml index f3f4ac501..cc453735d 100644 --- a/inst/extdata/sources/config_source_deaustralia.yml +++ b/inst/extdata/sources/config_source_deaustralia.yml @@ -515,7 +515,7 @@ sources: grid_system : "WRS-2" LS8-GEOMEDIAN : bands : - B01 : &deaustralia_ls5_geomedian_band_30m + B01 : &deaustralia_ls8_geomedian_band_30m missing_value : -999 minimum_value : 0 maximum_value : 65536 @@ -526,21 +526,21 @@ sources: band_name : "blue" data_type : "INT2S" B02 : - <<: *deaustralia_ls5_geomedian_band_30m + <<: *deaustralia_ls8_geomedian_band_30m band_name: "green" B03 : - <<: *deaustralia_ls5_geomedian_band_30m + <<: *deaustralia_ls8_geomedian_band_30m band_name: "red" B04 : - <<: *deaustralia_ls5_geomedian_band_30m + <<: *deaustralia_ls8_geomedian_band_30m band_name: "nir" B05 : - <<: *deaustralia_ls5_geomedian_band_30m + <<: *deaustralia_ls8_geomedian_band_30m band_name: "swir1" B07 : - <<: *deaustralia_ls5_geomedian_band_30m + <<: *deaustralia_ls8_geomedian_band_30m band_name: "swir2" - EDEV : &deaustralia_ls5_geomedian_product_30m + EDEV : &deaustralia_ls8_geomedian_product_30m missing_value : -32768 minimum_value : 0 maximum_value : 65536 @@ -551,10 +551,10 @@ sources: band_name : "edev" data_type : "FLT4S" SDEV : - <<: *deaustralia_ls5_geomedian_product_30m + <<: *deaustralia_ls8_geomedian_product_30m band_name: "sdev" BCDEV : - <<: *deaustralia_ls5_geomedian_product_30m + <<: *deaustralia_ls8_geomedian_product_30m band_name: "bcdev" satellite : "LANDSAT-8" sensor : "OLI-TIRS-GEOMEDIAN"