1

This question is a specific application of a previous question

I want to:

  1. Generate different groups of polygons (each belonging to a zone)
  2. Each polygon inside a zone would have a label that indicates which zone it belongs to.
  3. Then download a time series of the average (or any reducer) for EACH polygon. This time series should have a label that tells me what zone the polygon belongs to.

The way I tried to do this is by constructing a MultiPolygon (a set of buffers around points in my example) and then adding a label to the FeatureCollection they belong to. However, when I download the time series, I get (naturally) the average across polygons and not the average for each polygon.

I believe what I need to do is to turn the MultiPolygon into a FeatureCollection of Polygons, each with the same label...

Please see the code which has the example:

https://code.earthengine.google.com/0ed71b7645f904ab1c2a61ec10e7b548

0

You indeed cannot set properties to multipolygons, only to individual features. Therefore, you will need to build a feature of each polygon. To answer this question you actually ask:

I believe what I need to do is to turn the MultiPolygon into a FeatureCollection of Polygons, each with the same label...

//  Make a feature collection of the inputs
var fc = ee.FeatureCollection([geometry, geometry2, geometry3, geometry4, geometry5]);

// set type of geometry to each feature
fc = fc.map(function(feat){
  return ee.Feature(feat).set('type', ee.Feature(feat).geometry().type());
});

// rearrange the multipolygons into polygons
var onlyPolys = fc.map(function(feat){
  feat = ee.Feature(feat);
  var geometries = feat.geometry().geometries(); // return a list of each geometry
  var extractPolys = ee.FeatureCollection(geometries.map(function(poly){
    poly = ee.Geometry.Polygon(ee.Geometry(poly).coordinates());
    return ee.Feature(poly).copyProperties(feat);
  }));
  return extractPolys;
}).flatten();

print(onlyPolys)

See the link for the sample feature collection I draw.

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.