Context
Earthkit provides built-in plotting capabilities to visualize data retrieved from the HDA. This section presents examples of how to plot different types of data using earthkit-plots
. The available visualization methods vary depending on the dataset. For a complete overview, refer to the earthkit-plots documentation
If you haven't set up Earthkit yet, you can refer to this article to get started: Setting up Earthkit.
You'll find the code used in this article in the following notebook:
Loading datasets for visualization
To proceed with visualization, two different datasets from the previous sections will be used:
ERA5 Air Temperature (2m) β Monthly averaged reanalysis data by the hour of the day
CLMS Land Surface Temperature (LST) β 10-daily median values
Load the datasets using earthkit.data.from_source
:
ds_era5 = ekd.from_source("wekeo", "EO:ECMWF:DAT:REANALYSIS_ERA5_SINGLE_LEVELS_MONTHLY_MEANS", request={
"dataset_id": "EO:ECMWF:DAT:REANALYSIS_ERA5_SINGLE_LEVELS_MONTHLY_MEANS",
"product_type": ["monthly_averaged_reanalysis_by_hour_of_day"],
"variable": ["2m_temperature"],
"year": ["2020"],
"month": ["07"],
"time": ["00:00","01:00","02:00","03:00","04:00","05:00",
"06:00","07:00","08:00","09:00","10:00","11:00",
"12:00","13:00","14:00","15:00","16:00","17:00",
"18:00","19:00","20:00","21:00","22:00","23:00"],
"data_format": "netcdf",
"download_format": "zip",
"itemsPerPage": 200,
"startIndex": 0
})
ds_clms = ekd.from_source("wekeo", "EO:CLMS:DAT:CLMS_GLOBAL_LST_5KM_V1_10DAILY-DAILY-CYCLE_NETCDF", request = {
"dataset_id": "EO:CLMS:DAT:CLMS_GLOBAL_LST_5KM_V1_10DAILY-DAILY-CYCLE_NETCDF",
"productType": "LST10",
"resolution": "5000",
"startdate": "2020-07-01T00:00:00.000Z",
"enddate": "2020-07-02T23:59:59.999Z",
"itemsPerPage": 200,
"startIndex": 0
} )
With the data loaded, the next step is visualization using earthkit-plots
.
Plotting two different datasets side by side (same region)
This example visualizes and compares two datasets for the same region using earthkit-plots
:
ERA5 Air Temperature (2m) at 12:00 in July 2020
CLMS Land Surface Temperature (LST) Median at 12:00 on July 1, 2020
Side-by-side maps reveal differences between air and land surface temperatures, created with the earthkit-plots Figure
class for Europe:
figure = earthkit.plots.Figure(rows=1, columns=2)
dt_map = figure.add_map(domain="Europe")
dt_map.plot(ds_era5[11], units="kelvin")
dt_map.legend(location="bottom")
dt_map.title("ERA5 Air Temperature (2m) at 12:00 in July 2020")
eum_map = figure.add_map(domain="Europe")
eum_map.plot(ds_clms[59], units="kelvin")
eum_map.legend(location="bottom")
eum_map.title("CLMS LST Median on at 12:00 on 1st July.2020")
figure.land()
figure.gridlines()
figure.show()
Plotting two different datasets side by side (different regions)
This example compares datasets across regions using earthkit-plots
:
ERA5 Air Temperature (2m) at 12:00 in July 2020 over Germany
CLMS LST Median at 12:00 on July 1, 2020, over Spain
Side-by-side maps highlight regional temperature variations, created with the earthkit-plots Figure
class:
figure = earthkit.plots.Figure(rows=1, columns=2)
dt_map = figure.add_map(domain="Germany")
dt_map.plot(ds_era5[11], units="kelvin")
dt_map.legend(location="bottom")
dt_map.title("ERA5 Air Temperature (2m) at 12:00 in July 2020")
eum_map = figure.add_map(domain="Spain")
eum_map.plot(ds_clms[59], units="kelvin")
eum_map.legend(location="bottom")
eum_map.title("CLMS LST Median on at 12:00 on 1st July.2020")
figure.land()
figure.gridlines()
figure.show()
Plot each record of a dataset in a subplot
This example demonstrates how to visualize multiple time steps of a dataset using earthkit-plots
. Each subplot represents a different timestamp of ERA5 Air Temperature (2m) over Europe, allowing for an easy comparison of temporal variations:
figure = earthkit.plots.Figure(size=(12, 18), rows=6, columns=4)
for i in range(len(ds_era5.ls())):
dt_map = figure.add_map(domain="Europe")
dt_map.plot(ds_era5[i], units="kelvin")
date = str(ds_era5[i].slices[0].value.strftime("%Y-%m-%d %H:%M:%S"))
dt_map.title("ERA5 Air Temperature (2m) at \n"+date, fontsize=10)
figure.legend(location="bottom")
What's next?
Additional resources can be found in our Help Center. Should you require further assistance or wish to provide feedback, feel free to contact us through a chat session available in the bottom right corner of the page.