-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Milestone
Description
A common use case is to compute one or multiple new label (e.g. a band) while maintaining the source data cube. So for example compute the ndvi and evi for a data cube with 5 bands (1,2,3,4,5), which results in a data cube with 7 bands (1,2,3,4,5,ndvi,evi).
There are currently at least two ways to achieve this in openEO (pseudo-code):
// Alternative 1: apply_dimension
datacube = load_collection(...)
labels = dimension_labels(datacube, 'bands')
process = function(data) {
return data.concat([ndvi(data), evi(data)])
}
datacube = apply_dimension(datacube, process, 'bands')
labels = labels.concat(['ndvi', 'evi'])
result = rename_labels(datacube, 'bands', labels) // Rename required as apply_dimension discards labels in this case
// Alternative 2: reduce + merge
datacube = load_collection(...)
process = function(data) { return ndvi(data) }
ndvi = reduce_dimension(datacube, process, 'bands')
ndvi = add_dimension(ndvi, 'bands', 'ndvi', 'bands')
datacube = merge_cubes(datacube, ndvi);
process = function(data) { return evi(data) } // Assuming there's an evi process
evi = reduce_dimension(datacube, process, 'bands')
ndvi = add_dimension(evi , 'bands', 'evi ', 'bands')
result = merge_cubes(datacube, evi);
Both approaches are overly complex and annoying to implement. Therefore, two new ideas for discussion:
// Proposal A: add_labels
datacube = load_collection(...)
datacube = add_labels(datacube, ['ndvi', 'evi'], 'bands') // Adds new labels with no-data values
process = function(data) {
return array_modify(data, [ndvi(data), evi(data)], count(data, true) - 3, 2)
}
datacube = apply_dimension(datacube, process, 'bands')
// Proposal B: add_computed_labels
datacube = load_collection(...)
process = function(data) {
return array_create([ndvi(data), evi(data)])
}
ndvi = add_computed_labels(datacube, process, ['ndvi', 'evi'], 'bands') // Computes new values for two bands and adds them with the given labels
What are your thoughts on this? Which proposal is better? Should we add one of them? Both?
I feel like proposal B is the easiest to work with, but add_labels on its own could be useful, too.
Metadata
Metadata
Assignees
Labels
No labels