Example script for min EVI

library(openeo)
library(tibble)

Add credentials here (configure connect) or point to a R script that holds the credentials and cares for connection

host = "http://openeo.vgt.vito.be/openeo/0.4.2/"
con = connect(host = host)
capabilities()
list_service_types()
list_file_types()
colls = list_collections()
describe_collection(id = "S2_FAPAR_SCENECLASSIFICATION_V102_PYRAMID")
list_processes()
list_jobs()
p = processes()

# creating the graph
data = p$load_collection(id = p$data$SENTINEL2_L2A_SENTINELHUB,
                             spatial_extent = list(
                               west=16.1,
                               east=16.6,
                               south= 47.2,
                               north=48.6
                             ),
                             temporal_extent = list(
                               "2018-01-01", "2018-02-01"
                             ))

spectral_reduce = p$reduce(data = data, dimension = "bands", function(x) {
  B08 = x[8]
  B04 = x[4]
  B02 = x[2]
  (2.5 * (B08 - B04)) / sum(B08, 6 * B04, -7.5 * B02, 1)
})


temporal_reduce =  p$reduce(data = spectral_reduce,dimension = "temporal", reducer = p$min)


result = p$save_result(format="GTiff")

# print as JSON
graph = as(result, "Graph")
graph
# write to file 
cat(graphToJSON(graph),file = "vito-r-evi-phenology-graph.json")

# client side graph validation
graph$validate()

con %>% validate_process_graph(graph = graph)

# compute the result and check if the graph was valid
con %>% compute_result(graph=graph,format="GTiff",output_file = "vito-evi.tif")


flahn/openeo-r-client documentation built on Sept. 18, 2020, 5:16 a.m.