Context
The xcube software package has been developed to generate, manipulate, analyze and publish datacubes from Earth observation data. Please check you have installed xcube before going further.
You can also access the WEkEO JupyterHub and its Earth Observation Tools server, where xcube is installed. To find out more, go to the See xcube Viewer in action section of this article.
This guide aims to demonstrates how to display the datacube multi-dimensional array with the xcube Viewer in a browser.
You can download here the files needed to follow this article:
π Note: please extract the files before using them.
Create a configuration file
To add datacubes to the xcube Viewer, they have to be defined in a configuration file. The datacubes are stored locally, that's why we will now create a configuration file for locally stored datacubes. For remotely stored objects (e.g. on a s3 bucket) please refer to the official documentation.
The configuration file is stored with the name config.yml
in the same directory as the datacubes. In our case this is the working directory. There are two main parts in the configuration file: Datasets
and Styles
.
The Datasets
description contains:
Identifier: unique name for the datacube
Title: this is what the cube will be called in the Viewer
BoundingBox: spatial extent of the dataset
FileSystem: local or remote
Path: file name of cube in directory
Style: identifier of the style as defined below
TimeSeriesDataset: type of time series
The Styles
description contains:
Identifier: unique name for the style
ColorMappings:
VariableName: must be identical to the variable name in the cube
ColorBar: name of colorbar as in matplotlib
ValueRange: range of the dataset
You can copy the content below of the configuration file to the config.yml
file in your directory:
DatasetChunkCacheSize: 100M
Datasets:
- Identifier: local1
Title: LST Spain Cube
BoundingBox: [-10, 35, 4, 44]
FileSystem: file
Path: dc_lst_spain.zarr
Style: temp
TimeSeriesDataset: local_ts
- Identifier: local2
Title: Air Temp Spain Cube
BoundingBox: [-10, 35, 4, 44]
FileSystem: file
Path: dc_temp_spain.zarr
Style: temp
TimeSeriesDataset: local_ts
Styles:
- Identifier: temp
ColorMappings:
LST:
ColorBar: "inferno"
ValueRange: [250., 330.]
t2m:
ColorBar: "inferno"
ValueRange: [250., 330.]
π Note: you don't need to do this if you have downloaded the files at the beginning of this article.
Visualize the data in xcube
Now you can:
Open a terminal.
Go to the directory where you stored the datacubes and the configuration file.
Run the command
xcube serve -c config.yml --verbose &
The output will look like this:
Loaded service API 'auth'
Loaded service API 'styles'
...
Applying initial configuration...
Starting service...
Service running, listening on 0.0.0.0:8080
Try http://127.0.0.1:8080/openapi.html
Press CTRL+C to stop service
where http://127.0.0.1:8080/
is the server's endpoint in our case.
You can access to the Viewer by copy/pasting http://127.0.0.1:8080/viewer
Open this link in your web browser and the datacubes appear in the xcube Viewer:
See xcube Viewer in action
If you'd like to see the xcube Viewer in action, it is now possible to execute it inside the WEkEO JupyterHub. All necessary packages for the execution of the notebooks are installed in the python3 environment of the Earth Observation Tools Server.
β οΈ In the second notebook cell, insert the username in this url
βos.environ["XCUBE_JUPYTER_LAB_URL"] = https://jupyterhub.prod.wekeo2.eu/user/<your username>/
The first notebook teaches us how to create a datacube with climetlab and then visualize it with xcube Viewer.
You can access it via this button and then via the button:
This second notebook shows how the xcube Viewer can be used to visualize datacubes which are stored in a remote s3 bucket inside the Jupyter Notebook
You can access it via this button and then via the button:
What's next?
Feel free to check these articles that might be of interest for you:
If you have any question or feedback, feel free to contact us:
through a chat session available in the bottom right corner of the page
via our contact webpage
via e-mail to our support team (supportATwekeo.eu)
Regardless of how you choose to contact us, you will first be put in touch with our AI Agent Neo. At any time, you can reach a member of the WEkEO User Support team by clicking on "talk to a person" via chat, or by naturally requesting it in reply to Neo's email.