TransWikia.com

FeatureCollection (Error) Image.reduceRegions: Group input must come after weighted inputs

Geographic Information Systems Asked by Existential_Economist on September 28, 2021

I was trying to find the area of each block by category in the band. There is one band and it has 18 categories. The feature collection is a collection of blocks described uniquely by code_2011.

var image1 = ee.Image ("image_name");
var andhra = ee.FeatureCollection("Feature_name");

var image2 = ee.Image.pixelArea().addBands(image1);

var result = image2.reduceRegions({
    collection: andhra.select(['2011_code']),
    reducer: ee.Reducer.sum().group({
    groupField: 0,
    groupName: 'code',
  }),
    scale: 50
  }).filter(ee.Filter.neq('sum', null)
  ).flatten();

One Answer

You have to add a band to the existing band and call that band instead of the original one.

var image1 = ee.Image ("image_name");
var andhra = ee.FeatureCollection("Feature_name");

var image2 = ee.Image.addBands(image1);

var result = image2.reduceRegions({
    collection: andhra.select(['2011_code']),
    reducer: ee.Reducer.sum().group({
    groupField: 1,
    groupName: 'code',
  }),
    scale: 50
  }).filter(ee.Filter.neq('sum', null)
  ).flatten();

Answered by Existential_Economist on September 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP