When I dowload my images from the server I am missing the ndwi band in results. The ndwi calculation cube_ndwi = (B03 - B08) / (B03 + B08)
was done from cube bands and then it was added t cube its band. (cube.add(cube_ndwi))
howver I can not see the it ndwi in my final result. however I can see the ndvi which was calculated before. How ndwi can be added to final result?
Hi @sulova.andrea ,
Maybe the problem is theprocess you are using ot merge the datacubes:
I guess that âaddâ should be used to perform a sum, while you need probably to use the âmerge_cubesâ operation. Can you try and see if this resolve your issue?
@sulova.andrea as @paolo.filippucci said, you would need to use merge_cubes like this:
B03 = cube.band('B03')
B08 = cube.band('B08')
NDWI = (B03 - B08) / (B03 + B08)
NDWI = NDWI.add_dimension(name='bands',label='NDWI')
cube = cube.merge_cubes(NDWI)
The result will then contain B03, B08 and NDWI bands.
The most efficient approach is actually to use a built-in function from the client, itâs based on the âAwesome spectral indicesâ project, which supports a large number of predefined indices. In this case, you simply need âappend_indexâ
https://open-eo.github.io/openeo-python-client/cookbook/spectral_indices.html#openeo.extra.spectral_indices.append_index
So in your case, it becomes:
from openeo.extra.spectral_indices.spectral_indices import append_index
append_index(cube,"NDWI")
it avoids doing a âmerge_cubesâ, making it a bit faster.
Thank you! append_index
works well
Hi,
how can i use append_index in R?
The âawesome spectral indicesâ and this append_index
function are extra features specifically from the openEO Python client library. As far as I know there is no equivalent yet in other client libraries, like for R.
The Web Editor also supports the awesome spectral indices, but doesnât have append_index. Nevertheless, append_index is just a convenience function and can be emulated both in R and the Web Editor.
What processes does append_index use in the background, @stefaan.lippens ?
append_index does something like this
{
"process_id": "apply_dimension",
"arguments": {
"dimension": "bands",
"process": { "process_graph": {
... array_element ...
... array_element ...
... subtract ... add ... divide ...
"arraymodify1": {
"process_id": "array_modify",
"arguments": {
"data": {"from_parameter": "data"},
"index": 12,
"values": [{"from_node": "divide1"},],
},
"result": True,
},