How do I extract the specific values from NDVI time serie?

조회 수: 3 (최근 30일)
Devendra
Devendra 2024년 4월 5일
답변: Suraj Kumar 2024년 9월 9일
I have generated ndvi input file time series over crop season(1 year period) and want to extract the following; POS value;MAX sum;AVG sum;SOS;POS;EOS The discription of above mentioned parameters are as follows; (a) Phenological markers • Start of season (SOS): the date of growth start and crop emergence • Peak of season (POS): the date of the maximum NDVI value in the time series • End of season (EOS): the date of the harvesting and chlorophyll ab- sence • POS value: maximum NDVI value in the time series •
Average sum: sum of average NDVI values in the time series
• Maximum sum: sum of maximum NDVI values in the time series
• Base: the range between minimum and maximum NDVI
I am attaching input ndvi file as excel csv file. I am also attaching the output file as a sample it has not been derived from the above mentioned two input files. This is just sample output file. I am requesting to matlab signal processing comunity to please suggest me how to write this code. I would be highly obliged for any kind help.
Jyoti

답변 (1개)

Suraj Kumar
Suraj Kumar 2024년 9월 9일
Hi Devendra,
From what I understand, you are trying to extract specific phenological values from an NDVI time series using MATLAB.
For this you can refer to the following steps and the attached code snippets:
You can start by importing your NDVI data from the CSV file into MATLAB and then extract the dates and the NDVI values from the dataset.
% Load NDVI data from CSV
data = readtable('ndvi_time_series_input.csv');
% Extract dates and NDVI values
dates = data.Properties.VariableNames(2:end);
ndvi_values = data{:, 2:end};
Initialize the arrays using ‘NaT function in MATLAB, to store the desired results.
sos = zeros(size(ndvi_values, 1), 1);
pos = zeros(size(ndvi_values, 1), 1);
eos = zeros(size(ndvi_values, 1), 1);
pos_value = zeros(size(ndvi_values, 1), 1);
avg_sum = zeros(size(ndvi_values, 1), 1);
max_sum = zeros(size(ndvi_values, 1), 1);
base = zeros(size(ndvi_values, 1), 1);
Calculate the phenological markers by looping through each row of the NDVI data.
% Loop through each row in the NDVI data
for i = 1:size(ndvi_values, 1)
[pos_value(i), pos_idx] = max(ndvi_values(i, :));
pos(i) = datenum(dates{pos_idx}, 'yyyymmdd');
sos_idx = find(ndvi_values(i, :) > (min(ndvi_values(i, :)) + 0.1 * (pos_value(i) - min(ndvi_values(i, :)))), 1);
if ~isempty(sos_idx)
sos(i) = datenum(dates{sos_idx}, 'yyyymmdd');
end
eos_idx = find(ndvi_values(i, pos_idx:end) < (min(ndvi_values(i, :)) + 0.1 * (pos_value(i) - min(ndvi_values(i, :)))), 1);
if ~isempty(eos_idx)
eos(i) = datenum(dates{pos_idx + eos_idx - 1}, 'yyyymmdd');
end
avg_sum(i) = sum(ndvi_values(i, :)) / length(ndvi_values(i, :));
max_sum(i) = sum(max(ndvi_values(i, :)));
base(i) = range(ndvi_values(i, :));
end
Compile these calculations into a table for easy analysis and interpretation and display the results.
results = table(data{:, 1}, sos, pos, eos, pos_value, avg_sum, max_sum, base, ...
'VariableNames', {'Location', 'SOS', 'POS', 'EOS', 'POS_Value', 'Avg_Sum', 'Max_Sum', 'Base'});
disp(results);
You can look at the output for a better understanding:
For more details on theNaT or ‘datenum functions in MATLAB, you can refer to the following links:
Happy coding!

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by