I am trying to compare the NDVI-values of different land cover classes over a certain time period and display it in a chart. So in a first step, I'd like to extract the crop land cover and use its geometry to calculate just the NDVI of the croplands This is my code so far.

var area = ee.FeatureCollection('users/jonathanreith/KK')
var lc  = ee.Image("ESA/GLOBCOVER_L4_200901_200912_V2_3").select('landcover');

var crop = lc.eq(30)

// Convert the crop landcover to vectors.
var crop = crop.reduceToVectors({
  geometry: area,
  geometryType: 'polygon',
  eightConnected: false,
  labelProperty: 'landcover',
  scale: 300

var cropu = crop.union(1)

var NDVITimeSeries = ui.Chart.image.seriesByRegion({
    imageCollection: l8,
    regions: cropu,
    reducer: ee.Reducer.mean()

Unfortunately, crop consists of thousands of features, while union somehow erases all the information and just leaves the outer bounding box.

So how do I create an union feature with its geometries intact?
My Code
I already checked these Q&As:

1 Answer 1


If I understand correct, you need a MultiPoint Feature for the TimeSeries. I think you just need to filter the 'crop' FeatureCollection from reduceToVectors for the features containing the crop landcover by:

crop = crop.filter(ee.Filter.equals('landcover',1))

then you can extract the feauteres as one MultiPolygon with:

var cropu = crop.geometry()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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