I have the Sentinel 2 (COPERNICUS/S2) ImageCollection and a FeatureCollection of points. I want to extract a time series for each of the points from the band information in the ImageCollection.
So far I have the following code:
// Create a polygon to subset sentinel data var poly = ee.Geometry.Polygon( [[[13.932985323828689, -14.515258012418162], [13.932985323828689, -16.041324207881946], [15.690797823828689, -16.041324207881946], [15.690797823828689, -14.515258012418162]]], null, false); // Import sentinel data var sentinel2 = ee.ImageCollection("COPERNICUS/S2") .filterBounds(poly) // TESTING - Filter by polygon .filterDate('2016-02-01', '2019-02-10'); // TESTING - Filter on date // Create FeatureCollection of points var features = [ ee.Feature(ee.Geometry.Point(14.5, -15)), ee.Feature(ee.Geometry.Point(14.8, -15.1)), ee.Feature(ee.Geometry.Point(14.9, -15.2)) ]; var points = ee.FeatureCollection(features); // Define a function that works on a single point in the FeatureCollection var pointExtract = function(feat) { // Get geometry of point var geom = feat.geometry(); // Define a function that gets a point value for an image var pointGet = function(img, f) { // Duplicate feature var newf = ee.Feature(f); // Extract band value for pixel var value = img.reduceRegion(ee.Reducer.first(), geom, 30).get('B2'); // Return as a string in the duplicated feature return ee.Feature( newf.set(ee.String(value))); }; // Iterate over imageCollection to get time series var newfeat = ee.Feature(sentinel2.iterate(pointGet, feat)); return newfeat; }; // Iterate over points in FeatureCollection to extract time series var output = points.map(pointExtract); // Inspect output print(output); But I get the error:
FeatureCollection (Error) Error in map(ID=2): String: Parameter 'input' is required.