Open m-mohr opened 2 years ago
I try to state an example how it is currently implemented by creating the NDVI on GEE:
gee_host_url = "https://earthengine.openeo.org"
gee = connect(host = gee_host_url)
p = processes()
data1 = p$load_collection(id = "COPERNICUS/S2",
spatial_extent = list(west=-2.7634,south=43.0408,east=-1.121,north=43.8385),
temporal_extent = c("2018-04-30","2018-06-26"),
bands = c("B4","B8"))
ndvi = p$reduce_dimension(data = data1, dimension = "bands",reducer = function(x, context) {
B4 = x["B4"]
B8 = x["B8"]
return(p$normalized_difference(x = B4,y = B8))
})
reducer = p$reduce_dimension(data = ndvi,dimension = "t", reducer = function(x, context) {
min(x)
})
apply_linear_transform = p$apply(data = reducer, process = function(x,context) {
p$linear_scale_range(x = x, inputMin = -1, inputMax = 1,outputMin = 0,outputMax = 255)
})
final = p$save_result(data = apply_linear_transform,format = "PNG")
udp = as(final,"Process")
In this case udp
is the user defined process and it is a R6 object (the object oriented approach of R). As such I have implemented the functions setSummary
and setDescription
on that object (getter respectively). You can set the meta data manually with:
udp$setSummary("summary")
udp$setDescription("description")
However, in R you normally don't need the description here, so I have put those arguments in create_user_process()
and update_user_process()
, where you can state those information.
I think the field categories
was not defined in API 1.0.0, so this will be implemented, once I start to catch up to the changes for 1.1.0.
Thanks, I'll try to make this work in code gen.
Categories were available in 1.0.0 already, see https://api.openeo.org/1.0.0/index.html#operation/list-processes
So basically, I'd need setId, setSummary, setDescription, setCategories, setParameters, setReturns, setDeprecated, setExperimental, setExceptions, setExamples and setLinks (although setParameters and setReturns may be offered in a different way).
Yes, parameters and returns are derived automatically. Parameters are simply variables in the graph (create_variable
) and "return" is derived from the final node. For the others setId
, setSummary
and setDescription
are realized. Unfortunately the others are currently not supported, yet.
The use case here is to transform a well-defined process (e.g. with pre-defined parameter descriptions and return values) from JSON to R code automatically, so the auto-derivation doesn't really make sense as it would override what the user already wrote. Anyway, I'll do it step-by-step then and start with what is available and add the other stuff later once we make progress with this issue.
In JS I can do something like:
Which allows me to print the full metadata with all the additional metadata such as id, summary, categories. I'm not sure how I can set the metadata in R though. Is it possible? Or is this a missing feature?
I need this for code generation for example.