All Collections
WEkEO Trainings & Webinars
How to use the xcube Viewer?
How to use the xcube Viewer?

If you've just installed xcube and are wondering how to use it, this article is for you!

Alexandre avatar
Written by Alexandre
Updated over a week ago

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.

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:

  1. Open a terminal.

  2. Go to the directory where you stored the datacubes and the configuration file.

  3. 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, please follow this notebook in which we first use ClimetLab and then xcube to display the data:

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 e-mail to our support team (supportATwekeo.eu)

Did this answer your question?