The {CSDE} package provides an interface to the ‘Copernicus DataSpace Ecosystem’ API, mainly for searching the catalog of available data from Copernicus Sentinel missions and obtaining the images for just the area of interest based on selected spectral bands. The package uses the ‘Sentinel Hub’ REST API interface Sentinel Hub that provides access to various satellite imagery archives. It allows you to access raw satellite data, rendered images, statistical analysis, and other features.
OpenEO is an open-source project aimed at standardizing and simplifying access to Earth observation data and processing services. It provides a common API that abstracts away the complexities of accessing and processing Earth observation data, allowing users to interact with multiple back-end processing engines through a unified interface.
Both methods require registering on the Copernicus DataSpace. This vignette provides a detailed guide on acquiring Sentinel-2 imagery using both the CDSE (Copernicus Data and Exploitation Platform - SciHub) and the openEO platform.
To utilize the CDSE package for accessing Copernicus data, follow these steps:
Ensure you have the CDSE
and jsonlite
packages installed:
A Client secret will be generated. Make sure to copy your new personal OAuth secret immediately after it is created. You will not be able to see it again later.
Copy the new client id.
store_cdse_credentials
. Simply call it with the appropriate
client ID and secret as arguments. Alternatively, you can set
environment variables OAUTH_CLIENTID
and
OAUTH_SECRET
.# Example usage:
store_cdse_credentials(clientid = "your_client_id", secret = "your_secret_key")
# Alternatively, after setting your environment variables, you can use them like this:
store_cdse_credentials(Sys.getenv("OAUTH_CLIENTID"), Sys.getenv("OAUTH_SECRET"))
Afterward, you can utilize either optram_acquire_s2
or
acquire_scihub
# For this example, outputs are saved to `tempdir()`
from_date <- "2018-12-01"
to_date <- "2019-04-30"
# aoi <- {sf} object, POLYGON or MULTIPOLYGON of AOI area
# rOPTRAM_aoi_example
aoi <- sf::st_read(system.file("extdata",
"lachish.gpkg", package = 'rOPTRAM'))
boa_files <- acquire_scihub(aoi,
from_date, to_date,
veg_index = "SAVI",
output_dir = tempdir(),
SWIR_band = 11)
Alternatively, you can use the save_creds
option. At the
first run, set save_creds = TRUE
and enter your clientid
and secret as variables in the optram_acquire_s2
or
acquire_scihub
functions to automatically save credentials.
From there, you can use those functions as shown above without needing
to insert credentials again.
# For this example, outputs are saved to `tempdir()`
from_date <- "2018-12-01"
to_date <- "2019-04-30"
# rOPTRAM_aoi_example
optram_options("SWIR_band", 11)
optram_options("veg_index", "SAVI")
aoi <- sf::st_read(system.file("extdata",
"lachish.gpkg", package = 'rOPTRAM'))
boa_files <- acquire_scihub(aoi,
from_date, to_date,
veg_index = "SAVI",
output_dir = tempdir(),
# For the first run, uncomment below, and supply credentials...
# save_creds = TRUE,
# clientid = "your_client_id",
# secret = "your_secret"
)
optram_acquire_s2
or acquire_scihub
. To enable
the environment variable option, set save_creds = TRUE
when
calling either function. By doing so, you won’t need to manually enter
your Client ID and secret. Your code snippet might resemble the
following:from_date <- "2018-12-01"
to_date <- "2019-04-30"
# rOPTRAM_aoi_example
aoi <- sf::st_read(system.file("extdata",
"lachish.gpkg", package = 'rOPTRAM'))
boa_files <- acquire_scihub(aoi,
from_date, to_date,
output_dir = tempdir(),
# For the first run, uncomment below
# save_creds = TRUE,
)
# It will trigger the store_cdse_credentials function from utilities.R, and your
# credentials will be saved as a JSON file named cdse_credentials.json.
To use openEO for accessing Copernicus data, follow these steps:
Ensure you have the openeo
package installed:
For detailed instructions on how to register for the Copernicus Data Space, please visit: Registration Manual
A. When you run the acquire_openeo()
function, it
internally calls the check_openeo()
function. If the
openeo
package is not installed, it will be installed
automatically.
B. When prompted, press enter to proceed.
C. You will be redirected to the Copernicus authentication page. Log in and grant access.
You can specify your output_dir
parameter to indicate
the path where downloaded and processed imagery will be saved. For this
example, outputs are saved to tempdir()
This vignette provides comprehensive instructions for acquiring Sentinel-2 imagery using both CDSE and openEO platforms. Ensure you have the necessary credentials and packages installed to access Copernicus data efficiently.