-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
I'd like to point out that the latest changes to the Breizhcrops library affected the code in Breizhcrops Tutorial Colab Notebook
, so I'm going to point out the fixes.
Normalized Difference Vegetation Index
I think the error is probably caused by the addition of label, id to Bands.
I think the changes we made in this commit affected it.
It will work if you make the following changes.
def calculate_ndvi(input_timeseries):
# https://github.com/dl4sits/BreizhCrops/pull/24/commits/cbe3009c9adee06f51d252b1a734a1ba5636a2b6
# add ['label', 'id']
bands = allbands["L1C"].copy()
bands.remove('label')
bands.remove('id')
data = pd.DataFrame(input_timeseries,columns=bands)
data["doa"] = pd.to_datetime(data["doa"])
data = data.set_index("doa")
l1c_bands = ['B1', 'B10', 'B11', 'B12', 'B2', 'B3', 'B4',
'B5', 'B6', 'B7', 'B8','B8A', 'B9']
data[l1c_bands] *= 1e-4
nir = data["B8"]#
red = data["B4"]
return (nir-red) / (nir+red+1e-8)
dataset_index = 125 #@param {type:"slider", min:0, max:1048, step:1}
fig,axs = plt.subplots(1,2, figsize=(22,3))
ax = axs[0]
regular_dataset = breizhcrops.BreizhCrops(region="belle-ile", level="L1C", transform=raw_transform)
x,y,field_id = datasets["L1C"][dataset_index]
date = pd.to_datetime(x[:,-1])
x = x[:,:-1]
ax.plot(date,x[:,:-1])
ax.set_title("all spectral bands")
fig.suptitle(regular_dataset.classname[y])
ax = axs[1]
ndvi_dataset = breizhcrops.BreizhCrops(region="belle-ile", level="L1C", transform=calculate_ndvi)
x,y,field_id = ndvi_dataset[dataset_index]
ax.plot(x)
ax.set_title("NDVI")Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels