Geographic Information Systems Asked by Mar97 on March 10, 2021
I’m trying to obtain the NDSI index operating with a collection in GEE but always displays a error saying teres is a missing argument in a function and I cannot see the mistake as I followed the script of Google developers : https://developers.google.com/earth-engine/guides/ic_iterating
Does anyone know another way to oparate with image collections?
var dataset = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterDate('2018-01-01', '2019-12-31');
var series = dataset.map(function(image) {
return image.set('system:time_start', image.get('system:time_start'));
});
// This is a function to pass to Iterate().
// As NDSI images are computed, add them to the list.
var NDSI = function(image, list) {
var NDSIs = (image.select("B7").subtract(image.select("B3"))).divide(image.select("B7").add(image.select("B3")))
// Propagate metadata to the new image.
.set('system:time_start', image.get('system:time_start'));
// Return the list with the cumulative anomaly inserted.
return ee.List(list).add(NDSIs);
};
// Create an ImageCollection
// Since the return type of iterate is unknown, it needs to be cast to a List.
var NDSI_collection = ee.ImageCollection(ee.List(series.iterate(NDSI)));
print(NDSI)
I am not familiar with that index. However, following what I see in your code, you can apply it to an image collection the next way.
// your collection
var dataset = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterDate('2018-01-01', '2019-12-31');
// NDSI function
var addNDSI = function(image) {
var ndsi = image.normalizedDifference(['B7', 'B3']).rename('NDSI');
return image.addBands(ndsi);
};
// apply function to collection
var ndsi = dataset.map(addNDSI);
// Now any image of the collection has a new band with the NDSI
// For example, let's print the first image
print(ndsi.first());
// Let's visualize it (change min and max values as you like)
Map.addLayer(ndsi, {bands:'NDSI', min:-0.2, max:0.5}, 'NDSI');
Answered by HMSP on March 10, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP