So I'm trying to calculate the area with certain color, which those colors are representing certain range of value.
Here's the map
var indon = ee.FeatureCollection('users/sdwijati/IDN_adm2')
var Sesar = ee.FeatureCollection('users/sdwijati/Sesar_Jawa')
var nama_prov = ['Jawa Barat', 'Jakarta Raya', 'Jawa Tengah',
'Jawa Timur', 'Yogyakarta', 'Banten']
var prov = indon.filter(ee.Filter.inList('NAME_1', nama_prov));
var s = ee.Image("OpenLandMap/SOL/SOL_SAND-WFRACTION_USDA-3A1A1A_M/v02")
var savg = s.reduce(ee.Reducer.mean());
var gtsavg = savg.updateMask(savg.gte(45))
var n = ee.Image("OpenLandMap/SOL/SOL_WATERCONTENT-33KPA_USDA-4B1C_M/v01")
var navg = n.reduce(ee.Reducer.mean())
var xx = gtsavg.add(navg)
var sesar = Sesar
var bufferBy = function(size) {
return function(feature) {
return feature.buffer(size);
};
};
var intervals =
'<RasterSymbolizer>' +
'<ColorMap type="intervals" extended="false" >' +
'<ColorMapEntry color="#0CE84A" quantity="45" label="40" />' +
'<ColorMapEntry color="#FFF300" quantity="62.658" label="62.658" />' +
'<ColorMapEntry color="#FF1500" quantity="80.316" label="80.316" />' +
'<ColorMapEntry color="#000000" quantity="97.974" label="97.974" />' +
'</ColorMap>' +
'</RasterSymbolizer>';
var sarbuff = sesar.map(bufferBy(25000*4))
Map.addLayer(xx.sldStyle(intervals).clipToCollection(sarbuff).clip(prov));
Map.centerObject(prov, 7)
I'm trying to calculate the area of the color black (value 80.316-97.974), the code below doesn't work how it's supposed to, my guess is because instead of polygon for the geometry, it's a feature collection (which is kinda doubtful because the shapefile itself is basically a collection of polygons).
var sgttinggi = xx.updateMask(xx.lte(97.974))
var sgttinggi2 = sgttinggi.updateMask(sgttinggi.gt(80.316))
var stinggi = sgttinggi.clipToCollection(sarbuff).clip(prov)
var area_pxa = stinggi.multiply(ee.Image.pixelArea())
.reduceRegion(ee.Reducer.sum(),prov,250,null,null,false,1e13)
.get('mean')
area_pxa = ee.Number(area_pxa).divide(100000)
print ('Area Dengan Potensi Kerentanan Sangat Tinggi (km²)', area_pxa)
Yes, the code runs and it got a result, but the actual area of the island itself is about 138.000 km sq, and the result is way bigger than that. So, any idea on solving the problem? (Anyway shout out to Solved Scholar on Youtube for the code)