0

IMPORTS:

var geometry = /* color: #98ff00 */ee.Geometry.Polygon(
    [[[73.85016678395664, 14.304113379426035],
      [73.85016583974448, 14.048667693939866],
      [74.0477686190103, 14.155139129529527]]]),
    point1 = /* color: #d63000 */ee.Geometry.Point([73.91532897949219, 14.20980182205916]),
    point2 = /* color: #98ff00 */ee.Geometry.MultiPoint(
    [[73.9105224609375, 14.169860112219006],
     [73.87619018554688, 14.186503346854852],
     [73.87550354003906, 14.233097898500935],
     [73.93730163574219, 14.199817054773131],
     [73.95378112792969, 14.181177644664091],
     [73.88717651367188, 14.155213055929545],
     [73.92906188964844, 14.141230893912757],
     [73.94691467285156, 14.155878851710582],
     [73.97300720214844, 14.161205147702967],
     [73.98399353027344, 14.165865554216062],
     [73.9764404296875, 14.197820048470204]]);

CODE:

var image = ee.ImageCollection("LANDSAT/LC8_L1T_TOA").filterBounds(geometry)
.filterDate('2013-01-01', '2013-04-14');

var addNDWI = function(image) {
var ndwi = image.normalizedDifference(['B3', 'B6']).rename('NDWI');
return image.addBands(ndwi);
};
var image1 = image.map(addNDWI);

var fg_points = 
[ee.Feature(geometry),ee.Feature(point1),ee.Feature(point2)];
Map.addLayer(ee.Feature(geometry), {}, "geometry");
Map.addLayer(ee.Feature(point1), {}, "point1");
Map.addLayer(ee.Feature(point2), {}, "point2");


var mapfunc = function(feat) {
var geom = feat.geometry()
var addProp = function(img, f) {
var newf = ee.Feature(f)
var date = img.date().format()
var value = img.reduceRegion(ee.Reducer.first(), geom, 30).get('NDWI')
return ee.Feature(ee.Algorithms.If(value,
                                   newf.set(date, ee.String(value)),
                                   newf.set(date, ee.String('No data'))))
}
var newfeat = ee.Feature(image1.iterate(addProp, feat))
return newfeat
};


var newft = fg_points.map(mapfunc);

Export.table.toDrive(newft,
"export_Points",
"export_Points",
"export_Points");

Can someone explain where I am doing it wrong?

1

Your statement:

var newft = fg_points.map(mapfunc);

is mapping a function over a JavaScript list of features (fg_points) which results in newft being a list as well. You are then passing the list to Export.table.toDrive(), but a list is not a valid input parameter for the method. You need to convert it to a collection first:

var newft = ee.FeatureCollection(fg_points.map(mapfunc));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.