I'm new to javascript & GEE, trying to reduce a global FeatureCollection by computing sums of two specific properties, grouped by country (using this helpful link). The output is a Dictionary Object that contains all the info I need.
I'd like to reformat the data into rows and columns and then export it as a CSV.
What is the simplest way to do this?
// Call up WDPA data, filter
var dataset = ee.FeatureCollection('WCMC/WDPA/current/polygons')
.filter(ee.Filter.or(
ee.Filter.and(ee.Filter.eq('MARINE','0'),
ee.Filter.eq('IUCN_CAT','Ia')),
ee.Filter.and(ee.Filter.eq('MARINE','0'),
ee.Filter.eq('IUCN_CAT','Ib'))));
// Compute sums of protected area, grouped by country
var sums = dataset
.filter(ee.Filter.and(
ee.Filter.neq('GIS_AREA', null),
ee.Filter.neq('REP_AREA', null)))
.reduceColumns({
selectors: ['REP_AREA', 'GIS_AREA', 'PARENT_ISO'],
reducer: ee.Reducer.sum().repeat(2).group({
groupField: 2,
groupName: 'country',
})
});
print(sums);
I can export as a CSV from there, but it obviously comes out in Dictionary form (i.e. not terribly useful in a spreadsheet). This post almost addresses the question, but their initial output is a FeatureCollection, and mine is an Object. I couldn't get the chosen answer to work for me, and I'm just going in circles.