Skip to content

Commit

Permalink
examples update in ReadME
Browse files Browse the repository at this point in the history
  • Loading branch information
PondiB committed Nov 18, 2023
1 parent 41c2525 commit ae5b509
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 3 deletions.
77 changes: 74 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# OpenEOcubes: OpenEO Compliant Lightweight R Platform for Processing Time Series Satellite Images
# OpenEOcubes: openEO Compliant Lightweight R Platform for Processing Satellite Image Time Series

The service integrates STAC API (using Rstac package), the OpenEO standardized API, and data cubes concepts (using gdalcubes R package) to be a lightweight platform to enable analysis of time series satellite images via OpenEO Compliant RESTful endpoints using R-Client. It also supports users to run their custom R functions.

Expand Down Expand Up @@ -89,8 +89,79 @@ docker-compose build --no-cache && docker-compose up
```

## Getting Started:
### Example Script in R-Studio using OpenEO R-Client
Using openeo client version 1.1.0, the R scripts provided below has a user-defined function that uses bfast library to monitor changes on time series of Sentinel-2 imagery from 2016 to 2020. The study area is the region around the new Berlin-Brandenburg Tesla Gigafactory. You can run the code on your R-studio.

### Example 1: NDVI Script in R-Studio using OpenEO R-Client
Using openeo client version 1.3.0, the R scripts provided below calculate a 1-year period NDVI in a section of Amazonia in Brazil.

```bash
library(openeo)

# connect to the back-end when deployed locally
con = connect("http://localhost:8000")
# connect to the back-end when deployed on aws
# con = connect("http://<AWS-IPv4-ADDRESS>:8000")

# basic login with default params
login(user = "user",
password = "password")

# get the collection list
collections = list_collections()

# to check description of a collection
collections$`sentinel-s2-l2a-cogs`$description

# Check that required processes are available.
processes = list_processes()

# to check specific process e.g. ndvi
describe_process(processes$ndvi)

# get the process collection to use the predefined processes of the back-end
p = processes()

# load the initial data collection and limit the amount of data loaded
datacube_init = p$load_collection(id = "sentinel-s2-l2a-cogs",
spatial_extent = list(west=-7338335,
south=-1027138,
east=-7329987,
north=-1018790),
temporal_extent = c("2021-05-01", "2022-06-30"),
# extra args for data cubes regularization -> courtesy of gdalcubes
pixels_size = 30,
time_aggregation = "P1Y",
crs = 3857)

# filter the data cube for the desired bands
datacube_filtered = p$filter_bands(data = datacube_init, bands = c("B04", "B08"))


# ndvi calculation
datacube_ndvi = p$ndvi(data = datacube_filtered, red = "B04", nir = "B08")

# supported formats
formats = list_file_formats()

# save as GeoTiff or NetCDF
result = p$save_result(data = datacube_ndvi, format = formats$output$GTiff)

# Process and download data synchronously
start.time <- Sys.time()
compute_result(graph = result, output_file = "amazonia_2022_ndvi.tif")
end.time <- Sys.time()
time.taken <- end.time - start.time
time.taken
print("End of processes")

```

Visualization of the output from the above process:

![NDVI in Amazonia](docs/amazoniandvi.png)


### Example 2: BFAST change detection in R-Studio using OpenEO R-Client
Using openeo client version 1.3.0, the R scripts provided below has a user-defined function that uses bfast library to monitor changes on time series of Sentinel-2 imagery from 2016 to 2020. The study area is the region around the new Berlin-Brandenburg Tesla Gigafactory. You can run the code on your R-studio.

```bash
library(openeo)
Expand Down
Binary file added docs/amazoniandvi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ae5b509

Please sign in to comment.