Preparing Data for Analysis
This guide shows how to access and prepare different VZ-1 imagery products for further analysis.
We explore topics such as deriving brightness temperature from the Level-1 data and calculating NDVI from Level-2 surface reflectance.
1. Accessing Hydrosat's STAC API
We'll start by connecting to the STAC API and querying data from a specific area of interest (AOI) and time period of interest (TOI). See the Quick Start or Searching the Catalog guides for more detailed explanations of these steps.
1.1 Import dependencies
import json
import requests
import pystac
from pystac_client import Client
import base641.2 Authenticate and connect to the STAC API
To run the next cell, you should have set up a creds.json file containing your username and password in the same directory as this notebook.
with open('creds.json') as f:
creds = json.loads(f.read())
userpass = f"{creds['username']}:{creds['password']}"
b64 = base64.b64encode(userpass.encode()).decode()
headers = {'Authorization':'Basic ' + b64}
cat_url = 'https://stac.hydrosat.com/'
catalog = Client.open(cat_url, headers)2. Level-1 Data Products
We'll start by exploring some lower-level VZ-1 imagery. In particular, we'll show how the user can derive brightness temperature from Level-1 radiance data.
2.1 Calculating brightness temperature (BT) from the L1B data
Let's start by looking for data in the vz-l1b collection that intersects a specific AOI and TOI. Each Level-1B item contains assets representing top-of-atmosphere radiance from 7 VNIR and 2 LWIR spectral bands at 30 m spatial resolution.
Level-1A items also contain radiance data, but VNIR and LWIR data are stored separately and delivered at the native resolution of each imager. That is, ~30 m VNIR data is provided in the vz-viri-l1a collection and ~70 m LWIR data is available in the vz-liri-l1a collection.
2.1.1 Searching the catalog
Here, we'll convert the L1B data from digital numbers (DNs) to brightness temperature.
We'll focus on a specific item, defined by item_idx, in this example.
2.1.2 Accessing the metadata
We'll need to gather some information from the metadata for the brightness temperature conversion.
Let's start by retrieving the metadata JSON from the item of interest.
Here, we'll look through the file to better understand what it contains.
To calculate brightness temperature, we need to retrieve the gain, offset, and thermal constants from the metadata.
2.1.3 Converting DNs to radiance, and radiance to BT
Let's retrieve the LWIR data from the STAC item.
We can now convert the LWIR DNs to radiance using the gain and offset values from the metadata.
To convert radiance to brightness temperature, we'll use the thermal constants K1 and K2.
Here's a simple plotting function we'll use to visualize imagery throughout this notebook.
Now we're ready to display the brightness temperature data.

3. Level-2 Data Products
Level-2 data products include surface reflectance and LST. Here, we'll show how to access the L2 assets, apply necessary scaling factors, and calculate some derived products.
3.1 Retrieving surface temperature from the L2 data
We'll use rxr.open_rasterio() to access the LST COG.
We'll fill pixels containing no data with NaN values and apply a scaling factor before plotting the resulting image.

Hydrosat also provides information on LST uncertainty. Here, we'll access and plot the uncertainty data.

3.2 Calculating NDVI from the L2 data
The normalized difference vegetation index (NDVI) is a unitless value between -1 and 1 that is used as an indicator of vegetation greenness. It is calculated as:
Values closer to 1 represent healthy, green vegetation. (Healthy plants absorb more red light for photosynthesis, so the magnitude of the numerator is close to the magnitude of the denominator.)
Values closer to 0 represent bare ground or sparse vegetation.
Negative values tend to be associated with water or other nonvegetated surfaces.
Here, we'll walk through the process of calculating NDVI, starting by accessing NIR and red surface reflectance data.
3.2.1 Retrieving data from the NIR and red bands


3.2.2 Calculating and visualizing NDVI

That's it! You've seen how to analyze and calculate some derived products from Hydrosat data.
Last updated
Was this helpful?