Моя задача — вычислить среднее, минимальное, максимальное, медианное значение и некоторые процентили для нескольких индексов растительности, полученных на основе изображений Sentinel-2. .
Для каждого сайта меня интересуют 4-5 разных дат; даты различаются на разных сайтах. Все даты попадают где-то между 2020 и 2024 годами.
Вот мое недоумение: Я хотел бы включить для расчета зональной статистики только те пиксели, которые попадают по крайней мере 70 % их поверхности в моих полигонах.
Я постарался лучше объяснить ситуацию на рисунках A и B.

Я вполне уверен, что взвешенный /невзвешенные редукторы не помогут; плюс, я не думаю, что это имеет какой-либо смысл, поскольку мы говорим об индексах растительности.
Насколько я знаю, у ee.Image.reduceRegion нет аргументов для контроля такого аспекта .
На данный момент я работал только с 1 сайтом. Я работаю на Java. Следующие шаги уже успешно выполнены:
- Импорт шейп-файла и коллекции функций S2 уровня 2A.
- фильтр коллекции по периоду исследования и по границам.
- вычисление некоторые из представляющих интерес индексов растительности. Индексы сохранены в переменной SoloIndices.
- Вычисление желаемых значений для каждого индекса (среднее, минимальное, максимальное и различные процентили). .
// 1) import the vector of the area;
// 2) import the S2 collection
// 3) filter the collection by date and extent
// 4) write a function to calculate the spectral indices for each image of the collection and add the index in a new file
// 5) calculate the stats for each polygon
// 6) export in a table
// 1) import the vector of the area;
var cp2 = ee.FeatureCollection('projects/ee-sebastianilsn3/assets/CP2');// area imported
var cp2g = cp2.geometry();// area converted to geometry
// 2) import the S2 collection 3) filter the collection by date and extent
var filtered = s2.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 30))
.filter(ee.Filter.date('2020-01-01', '2023-12-01'))
.filter(ee.Filter.bounds(cp2g)); //collection imported and filtered
//4) write a function to calculate the spectral indices for each image of the collection and add the index in a new file
function addIndices(image) {
var ndvi = image.normalizedDifference(['B8', 'B4']).rename('ndvi');
var ndwi = image.normalizedDifference(['B3', 'B8']).rename('ndwi');
var savi = image.expression(
'1.5 * ((NIR - RED) / (NIR + RED + 0.5))', {
'NIR': image.select('B8'),
'RED': image.select('B4'),
}).rename('savi');
var reip = image.expression(
'700 + 40 * ((R + RE7)/2 - RE5) / (RE6 - RE5)', {
'R': image.select('B4'),
'RE7': image.select('B7'),
'RE5': image.select('B5'),
'RE6': image.select('B6'),
}).rename('reip');
return image.addBands(ndvi).addBands(ndwi).addBands(savi).addBands(reip);
}
var withIndices = filtered.map(addIndices); // map the function over the filtered collection
var soloIndices =withIndices.select('ndvi', 'ndwi','savi','reip'); // creating a new item containing only the VIs
var soloNdvi = withIndices.select('ndvi');
//print(soloNdvi, 'solo NDVI');
var soloNdwi = withIndices.select('ndwi');
//print(soloNdwi, 'solo NDWI');
var composite = withIndices.median();
var ndviComp = composite.select('ndvi'); // this way I get the ndvi!
// here i add the map of NDVI
var palette = [
'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
'74A901', '66A000', '529400', '3E8601', '207401', '056201',
'004C00', '023B01', '012E01', '011D01', '011301'];
var ndviVis = {min: 0.3, max: 0.8, bands: ['ndvi'], palette: palette};
// this is the function to extract the desired statistics from the Vegetation indices
var valueComp = function(image){
var reduct = image.reduceRegion({
reducer: ee.Reducer.mean().unweighted().combine({reducer2: ee.Reducer.min(), sharedInputs: true} )
.combine({reducer2: ee.Reducer.max(), sharedInputs: true} )
.combine({reducer2: ee.Reducer.percentile([25]), sharedInputs: true} )
.combine({reducer2: ee.Reducer.percentile([50]), sharedInputs: true} )
.combine({reducer2: ee.Reducer.percentile([75]), sharedInputs: true} ),
geometry: cp2,
scale: 10,
maxPixels: 1e10
});
// Extract the properties from the dictionary and then form the list
reduct = ee.List(ee.Dictionary(reduct));
// Put the results into a Feature without geometry
return ee.Feature(null, reduct); // che cosa è reduct? una list?
}; // function is complete
// 5) calculate the stats for each polygon
var result = soloIndices.map(valueComp); // here I map the function over the collection
print(result);
// 6) export in a table
Export.table.toDrive({
collection: result,
folder: 'GEE TESTS',
description:'VEG_IND_S2',
fileFormat: 'CSV'
}); // here I export the table
Подробнее здесь: https://stackoverflow.com/questions/790 ... ls-falling