I try to get the sum of my pixel information (carbon content by pixel) and pixel number of an image in my feature collections property BIOTYP8. Output should be carbon content and area of different codes of the property BIOTYP8. Example: 0836 is Birch forest and has total X pixels stored and XXXX total sum of carbon. I tried to rasterize the feature collection, add the bands to the carbon image, but the analysis won't work. Can anyone help or has a better approach?
Map.addLayer(JRC18C,vizParamsC,'JRC18 carbon content');
Map.addLayer(ESA18C,vizParamsC,'ESA18 carbon content');
Map.addLayer(CIRB_f,{},'Forest Biotopes');
var CIRB_fn=CIRB_f.map(function(feature){
var num = ee.Number.parse(feature.get('BIOTYP8'));
return feature.set('BIOTYP8', num);
});
function getCols(tableMetadata) {
print(tableMetadata.columns);
}
///Check on pixel in total covered by Biotopes
var Biot_pixelDic_ESAC = ESA18C.reduceRegion({
reducer: ee.Reducer.count(),
geometry: CIRB_f,
scale: 100,
maxPixels: 1e9
});
print('Area of ESA forest in CIRB', Biot_pixelDic_ESAC);
var Biot_pixelDic_JRCC = JRC18C.reduceRegion({
reducer: ee.Reducer.count(),
geometry: CIRB_f,
scale: 100,
maxPixels: 1e9
});
print('Area of JRC forest in CIRB', Biot_pixelDic_JRCC);
//Total stored carbon in biotopes classes
var Biot_sum_ESAC = ESA18C.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: CIRB_f,
scale: 100,
maxPixels: 1e9
});
print('Sum of ESA forest carbon in CIRB', Biot_sum_ESAC);
var Biot_sum_JRCC = JRC18C.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: CIRB_f,
scale: 100,
maxPixels: 1e9
});
print('Area of JRC forest carbon in CIRB', Biot_sum_JRCC);
/////////////////// Area by class
//transform vector to image
var CIRB_fi = CIRB_fn.filter(ee.Filter.notNull(['BIOTYP8']))
.reduceToImage({
properties: ['BIOTYP8'],
reducer: ee.Reducer.first(),
});
Map.setCenter(13.5145, 52.924, 12);
Map.addLayer(CIRB_fi, {},'CIRB forest image');
//merge image bands
var ESA18C_bioclass= CIRB_fi.addBands(ESA18C);
Map.addLayer(ESA18C_bioclass,{},'ESA18C + Biotopes');
var DIcBiotopes_ESAC = ESA18C_bioclass.reduceRegion({
reducer: ee.Reducer.sum().group({
groupField: 1,
groupName: 'BIOTYP8',
}),
geometry: CIRB_f.geometry,
scale: 100,
crs:3035,
maxPixels: 1e9
});
print('Biotypes of ESA forest', Biotopes_ESAC);
Which receives this error for the var DIcBiotopes_ESAC line:
Invalid GeoJSON geometry: undefined