Reputation: 1
I am trying to extract mean SI value and B3, B4 bands value of some point in area into csv . but get the error: Error: Error in map(ID=0): Feature, argument 'metadata': Invalid type. Expected type: Dictionary. Actual type: Image<[SI]>. (Error code: 3)
How to fix it. Here my code:
// study area
var TV = ee.FeatureCollection('projects/honghanh/assets/kvnc_travinh');
// Load Sentinel-2 data.
var s2 = ee.ImageCollection('COPERNICUS/S2');
// Load cloud masking tool
var s2mask = require('users/fitoprincipe/geetools:cloud_masks').sentinel2;
// function to apply SI calculation to every image in collection
function addSI(image) {
var SI = image.expression('((B3*B3)+(B4*B4))**0.5', {
'B3': image.select('B3'),
'B4': image.select('B4')
}).rename('SI'); // Rename the resulting band to 'SI'
return image.addBands(SI);
}
//set a list of start dates
var startDate = '2020-05-01';
var endDate = '2020-09-30';
var interval = 10;
var increment = 'day';
var tendayDifference = ee.Date(startDate).advance(interval, increment).millis().subtract(ee.Date(startDate).millis());
var listMap = ee.List.sequence(ee.Date(startDate).millis(), ee.Date(endDate).millis(), tendayDifference);
//function to get a tenday composite
function gettendaySentinelComposite(date) {
// Only include the SI
var s2_filtered = ee.ImageCollection('COPERNICUS/S2')
.filterBounds(TV)
.filterDate(date, ee.Date(date).advance(interval, increment))
.filterMetadata('CLOUDY_PIXEL_PERCENTAGE', 'less_than', 60)
.map(s2mask())
.map(addSI)
.select('SI');
var composite = s2_filtered.max()
.set('system:time_start', date.millis(), 'dateYMD', ee.Date(date).format('YYYY-MM-dd'), 'numbImages', s2_filtered.size());
return composite;
}
var si_tenday = ee.ImageCollection.fromImages(listMap.map(function(dateMillis){
var date = ee.Date(dateMillis);
return gettendaySentinelComposite(date);
}));
print(si_tenday);
// Convert the image collection to a feature collection
var features = si_tenday.map(function(image) {
return ee.Feature(ee.Geometry.Point([106.13544061978001,9.848671705624335], [106.33868769009251,9.802664710280455],
[106.49249628384251,9.674478022266713]),
[106.50348261196751,9.706966705826082],
image.select('SI'));
});
// Export the feature collection to a CSV file
Export.table.toDrive({
collection: features.select('SI').mean(),
description: 'selected_bands_data',
fileFormat: 'CSV'
});
How to fix the error
Upvotes: 0
Views: 20