我在GIS StackExchange上问过这个问题,但到目前为止还没有运气。我想也许它属于这里。
我使用了以下脚本:
// define the var
var Catchment = /* color: 98ff00 */geometry;
var landcover = ee.Image('users/roynahas/ESACCI-LC-L4-LCCS-Map-300m-P5Y-2010-v161_RECLASS').select('b1');
// Clip the image to the polygon geometry and add it to the map
var landcover_clip = landcover.clip(Catchment);
var sld_intervals =
'<RasterSymbolizer>' +
'<ColorMap type="intervals" extended="false" >' +
'<ColorMapEntry color="#FFFF00" quantity="1" label="Agriculture"/>' +
'<ColorMapEntry color="#00FF00" quantity="2" label="Grassland and Shrubland"/>' +
'<ColorMapEntry color="#008000" quantity="3" label="Forest"/>' +
'<ColorMapEntry color="#00FFFF" quantity="4" label="Flooded"/>' +
'<ColorMapEntry color="#FF00FF" quantity="5" label="Urban areas"/>' +
'<ColorMapEntry color="#808080" quantity="6" label="Bare areas"/>' +
'<ColorMapEntry color="#0000FF" quantity="7" label="Water"/>' +
'<ColorMapEntry color="#FFFFFF" quantity="8" label="Permanent snow and ice"/>' +
'</ColorMap>' +
'</RasterSymbolizer>';
Map.addLayer(landcover_clip.sldStyle(sld_intervals), {}, 'IGBP classification styled');
// Print out the frequency of landcover occurrence for the polygon.
var frequency = landcover.reduceRegion({
reducer:ee.Reducer.frequencyHistogram(),
geometry:Catchment,
scale:300
});
print('landcover frequency', frequency.get('b1'));
要获得以下控制台输出:
所以我的问题是:我怎样才能有一个百分比而不是一个频率?或者换句话说:是否有相当于 ee.Reducer.frequencyHistogram() 的百分比?