diff --git a/inst/extdata/sources/config_source_deafrica.yml b/inst/extdata/sources/config_source_deafrica.yml index 32e2597a..c6d15699 100644 --- a/inst/extdata/sources/config_source_deafrica.yml +++ b/inst/extdata/sources/config_source_deafrica.yml @@ -55,7 +55,7 @@ sources: resolution : 30 data_type : "FLT4S" missing_value : -32768 - minimum_value : 0 + minimum_value : -32767 maximum_value : 65534 scale_factor : 1 offset_value : 0 @@ -521,3 +521,259 @@ sources: metadata_search : "tile" ext_tolerance: 0 grid_system : "MGRS" + + GM-LS8-LS9-ANNUAL : + bands: + B02: &deafrica_ls_gm_annual_30m + band_name : "SR_B2" + resolution : 30 + data_type : "INT2U" + missing_value : 0 + minimum_value : 1 + maximum_value : 65455 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + B03: + <<: *deafrica_ls_gm_annual_30m + band_name: "SR_B3" + B04: + <<: *deafrica_ls_gm_annual_30m + band_name: "SR_B4" + B05: + <<: *deafrica_ls_gm_annual_30m + band_name: "SR_B5" + B06: + <<: *deafrica_ls_gm_annual_30m + band_name: "SR_B6" + B07: + <<: *deafrica_ls_gm_annual_30m + band_name: "SR_B7" + EMAD: &deafrica_ls_gm_annual_metrics_30m + band_name : "EMAD" + resolution : 10 + data_type : "FLT4S" + missing_value : -3.402823466385288e+37 + minimum_value : -3.402823466385288e+37 + maximum_value : 1.7014118346015974e+37 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + SMAD: + <<: *deafrica_ls_gm_annual_metrics_30m + band_name : "SMAD" + BCMAD: + <<: *deafrica_ls_gm_annual_metrics_30m + band_name: "BCMAD" + satellite: "LANDSAT" + sensor: "OLI" + collection_name: "gm_ls8_ls9_annual" + 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" + GM-S2-ANNUAL : + bands: + B02: &deafrica_sentinel_gm_annual_10m + band_name : "B02" + resolution : 10 + data_type : "INT2U" + missing_value : 0 + minimum_value : 1 + maximum_value : 65455 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + B03: + <<: *deafrica_sentinel_gm_annual_10m + band_name: "B03" + B04: + <<: *deafrica_sentinel_gm_annual_10m + band_name: "B04" + B05: + <<: *deafrica_sentinel_gm_annual_10m + band_name: "B05" + B06: + <<: *deafrica_sentinel_gm_annual_10m + band_name: "B06" + B07: + <<: *deafrica_sentinel_gm_annual_10m + band_name: "B07" + B08: + <<: *deafrica_sentinel_gm_annual_10m + band_name: "B08" + B11: + <<: *deafrica_sentinel_gm_annual_10m + band_name: "B11" + B12: + <<: *deafrica_sentinel_gm_annual_10m + B8A: + <<: *deafrica_sentinel_gm_annual_10m + band_name: "B8A" + EMAD: &deafrica_sentinel_gm_annual_metrics_10m + band_name : "EMAD" + resolution : 10 + data_type : "FLT4S" + missing_value : -3.402823466385288e+37 + minimum_value : -3.402823466385288e+37 + maximum_value : 1.7014118346015974e+37 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + SMAD: + <<: *deafrica_sentinel_gm_annual_metrics_10m + band_name : "SMAD" + BCMAD: + <<: *deafrica_sentinel_gm_annual_metrics_10m + band_name: "BCMAD" + satellite: "SENTINEL-2" + sensor: "MSI" + collection_name: "gm_s2_annual" + 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" + GM-S2-ROLLING : + bands: + B02: &deafrica_sentinel_gm_rolling_10m + band_name : "B02" + resolution : 10 + data_type : "INT2U" + missing_value : 0 + minimum_value : 1 + maximum_value : 65534 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + B03: + <<: *deafrica_sentinel_gm_rolling_10m + band_name : "B03" + B04: + <<: *deafrica_sentinel_gm_rolling_10m + band_name : "B04" + B05: + <<: *deafrica_sentinel_gm_rolling_10m + band_name : "B05" + B06: + <<: *deafrica_sentinel_gm_rolling_10m + band_name : "B06" + B07: + <<: *deafrica_sentinel_gm_rolling_10m + band_name : "B07" + B08: + <<: *deafrica_sentinel_gm_rolling_10m + band_name : "B08" + B11: + <<: *deafrica_sentinel_gm_rolling_10m + band_name : "B11" + B12: + <<: *deafrica_sentinel_gm_rolling_10m + band_name : "B12" + B8A: + <<: *deafrica_sentinel_gm_rolling_10m + band_name : "B8A" + EMAD: &deafrica_sentinel_gm_annual_metrics_10m + band_name : "EMAD" + resolution : 10 + data_type : "FLT4S" + missing_value : -3.402823466385288e+37 + minimum_value : -3.402823466385288e+37 + maximum_value : 1.7014118346015974e+37 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + SMAD: + <<: *deafrica_sentinel_gm_annual_metrics_10m + band_name: "SMAD" + BCMAD: + <<: *deafrica_sentinel_gm_annual_metrics_10m + band_name: "BCMAD" + satellite: "SENTINEL-2" + sensor: "MSI" + collection_name: "gm_s2_rolling" + 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" + GM-S2-SEMIANNUAL : + bands: + B02: &deafrica_sentinel_gm_semiannual_10m + band_name : "B02" + resolution : 10 + data_type : "INT2U" + missing_value : 0 + minimum_value : 1 + maximum_value : 65455 + scale_factor : 0.0001 + offset_value : 0 + resampling : "bilinear" + B03: + <<: *deafrica_sentinel_gm_semiannual_10m + band_name : "B03" + B04: + <<: *deafrica_sentinel_gm_semiannual_10m + band_name : "B04" + B05: + <<: *deafrica_sentinel_gm_semiannual_10m + band_name : "B05" + B06: + <<: *deafrica_sentinel_gm_semiannual_10m + band_name : "B06" + B07: + <<: *deafrica_sentinel_gm_semiannual_10m + band_name : "B07" + B08: + <<: *deafrica_sentinel_gm_semiannual_10m + band_name : "B08" + B11: + <<: *deafrica_sentinel_gm_semiannual_10m + band_name : "B11" + B12: + <<: *deafrica_sentinel_gm_semiannual_10m + band_name : "B12" + B8A: + <<: *deafrica_sentinel_gm_semiannual_10m + band_name : "B8A" + EMAD: &deafrica_sentinel_gm_semiannual_metrics_10m + band_name : "EMAD" + resolution : 10 + data_type : "FLT4S" + missing_value : -3.402823466385288e+37 + minimum_value : -3.402823466385288e+37 + maximum_value : 1.7014118346015974e+37 + scale_factor : 1 + offset_value : 0 + resampling : "bilinear" + SMAD: + <<: *deafrica_sentinel_gm_semiannual_metrics_10m + band_name: "SMAD" + BCMAD: + <<: *deafrica_sentinel_gm_semiannual_metrics_10m + band_name: "BCMAD" + satellite: "SENTINEL-2" + sensor: "MSI" + collection_name: "gm_s2_semiannual" + 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/tests/testthat/test-cube-deafrica.R b/tests/testthat/test-cube-deafrica.R index 024d46bd..05fe0bf4 100644 --- a/tests/testthat/test-cube-deafrica.R +++ b/tests/testthat/test-cube-deafrica.R @@ -299,6 +299,147 @@ test_that("Creating Sentinel-1 RTC cubes from DEA using tiles", { expect_true(all(c("VV") %in% sits_bands(cube_s1_reg))) }) +test_that("Creating Landsat-8/9 Geomedian (Annual) from DEA", { + landsat_cube <- .try( + { + sits_cube( + source = "DEAFRICA", + collection = "GM-LS8-LS9-ANNUAL", + bands = c("B05"), + roi = c( + lon_min = 33.546, + lon_max = 34.999, + lat_min = 1.427, + lat_max = 3.726 + ), + start_date = "2021-01-01", + end_date = "2022-01-01", + progress = FALSE + ) + }, + .default = NULL + ) + + testthat::skip_if(purrr::is_null(landsat_cube), + message = "DEAFRICA is not accessible" + ) + + expect_true(all(sits_bands(landsat_cube) %in% c("B05"))) + expect_equal(nrow(landsat_cube), 12) + bbox_cube <- sits_bbox(landsat_cube, as_crs = "EPSG:4326") + bbox_cube_1 <- sits_bbox(.tile(landsat_cube), 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(landsat_cube$file_info[[1]]$path[1]) + cube_nrows <- .tile_nrows(landsat_cube) + expect_true(.raster_nrows(r_obj) == cube_nrows) +}) +test_that("Creating Sentinel-2 Geomedian (Annual) from DEA", { + sentinel_cube <- .try( + { + sits_cube( + source = "DEAFRICA", + collection = "GM-S2-ANNUAL", + bands = c("B05"), + roi = c( + lon_min = 33.546, + lon_max = 34.999, + lat_min = 1.427, + lat_max = 3.726 + ), + start_date = "2021-01-01", + end_date = "2022-01-01", + progress = FALSE + ) + }, + .default = NULL + ) + + testthat::skip_if(purrr::is_null(sentinel_cube), + message = "DEAFRICA is not accessible" + ) + + expect_true(all(sits_bands(sentinel_cube) %in% c("B05"))) + expect_equal(nrow(sentinel_cube), 12) + bbox_cube <- sits_bbox(sentinel_cube, as_crs = "EPSG:4326") + bbox_cube_1 <- sits_bbox(.tile(sentinel_cube), 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(sentinel_cube$file_info[[1]]$path[1]) + cube_nrows <- .tile_nrows(sentinel_cube) + expect_true(.raster_nrows(r_obj) == cube_nrows) +}) +test_that("Creating Sentinel-2 Geomedian (Semiannual) from DEA", { + sentinel_cube <- .try( + { + sits_cube( + source = "DEAFRICA", + collection = "GM-S2-ANNUAL", + bands = c("B05"), + roi = c( + lon_min = 33.546, + lon_max = 34.999, + lat_min = 1.427, + lat_max = 3.726 + ), + start_date = "2021-01-01", + end_date = "2022-01-01", + progress = FALSE + ) + }, + .default = NULL + ) + + testthat::skip_if(purrr::is_null(sentinel_cube), + message = "DEAFRICA is not accessible" + ) + + expect_true(all(sits_bands(sentinel_cube) %in% c("B05"))) + expect_equal(nrow(sentinel_cube), 12) + bbox_cube <- sits_bbox(sentinel_cube, as_crs = "EPSG:4326") + bbox_cube_1 <- sits_bbox(.tile(sentinel_cube), 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(sentinel_cube$file_info[[1]]$path[1]) + cube_nrows <- .tile_nrows(sentinel_cube) + expect_true(.raster_nrows(r_obj) == cube_nrows) +}) +test_that("Creating Sentinel-2 Geomedian (Rolling) from DEA", { + sentinel_cube <- .try( + { + sits_cube( + source = "DEAFRICA", + collection = "GM-S2-ROLLING", + bands = c("B05", "B8A"), + roi = c( + lon_min = 33.546, + lon_max = 34.999, + lat_min = 1.427, + lat_max = 3.726 + ), + start_date = "2021-01-01", + end_date = "2022-01-01", + progress = FALSE + ) + }, + .default = NULL + ) + + testthat::skip_if(purrr::is_null(sentinel_cube), + message = "DEAFRICA is not accessible" + ) + + expect_true(all(sits_bands(sentinel_cube) %in% c("B05", "B8A"))) + expect_equal(nrow(sentinel_cube), 12) + bbox_cube <- sits_bbox(sentinel_cube, as_crs = "EPSG:4326") + bbox_cube_1 <- sits_bbox(.tile(sentinel_cube), 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(sentinel_cube$file_info[[1]]$path[1]) + cube_nrows <- .tile_nrows(sentinel_cube) + expect_true(.raster_nrows(r_obj) == cube_nrows) +}) + test_that("Creating ALOS-PALSAR-MOSAIC cubes from DEA", { cube_alos <- .try( {