Skip to main content

Hi sentinelHub-Forum-Team,


I downloaded already Sentinel2-Bands.

Now i want to add the NDVI and other indices.

Do you have an example for the task?


Thank you in advance

Hi,

Here is a dedicated example demonstrating how you could work with eo-learn package.

Section 2. -4 demonstrates how you could create EOPatches, fill them with Sentinel-2 data, and compute indices using Sentinel Hub services.


Hi,


thanks for answering.

In this case: I have downloaded the bands for NDVI. The Data-download is completed.

Now I have to calculate the index with the EOPatch-Data witch is already on the the disk.

Can you give an example, how to do it?

I have no clue. I only find examples with downloading the data again/new.


Thank you very much for your help.


The example shows actually uses already downloaded bands (in that particular case, the downloaded bands are ["B02", "B03", "B04", "B08", "B11", "B12"]) to calculate NDVI.

To download:

band_names = ["B02", "B03", "B04", "B08", "B11", "B12"]
add_data = SentinelHubInputTask(
bands_feature=(FeatureType.DATA, "BANDS"),
bands=band_names,
resolution=10,
maxcc=0.8,
time_difference=datetime.timedelta(minutes=120),
data_collection=DataCollection.SENTINEL2_L1C,
additional_data=[(FeatureType.MASK, "dataMask", "IS_DATA"), (FeatureType.MASK, "CLM"), (FeatureType.DATA, "CLP")],
max_threads=5,
)

To calculate NDVI, NormalizedDifferenceIndexTask task is used:

# NDVI: (B08 - B04)/(B08 + B04)
ndvi = NormalizedDifferenceIndexTask(
(FeatureType.DATA, "BANDS"), (FeatureType.DATA, "NDVI"), [band_names.index("B08"), band_names.index("B04")]
)

If you already have data downloaded, then you can load your eopatch(es) with LoadTask, which will load the existing eopatches in memory, and run ndvi task as defined above on it.


Reply