Geographic Information Systems Asked on October 1, 2021
Ok so let’s just jump right to the script
var indon = ee.FeatureCollection('users/sdwijati/IDN_adm2')
var Sesar = ee.FeatureCollection('users/sdwijati/Sulawesi_sesar')
var nama_prov = ['Sulawesi Tengah', 'Sulawesi Utara',
'Sulawesi Tenggara', 'Sulawesi Barat',
'Gorontalo', 'Sulawesi Selatan']
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()); //Mean soil sand content
var smap = savg.divide(20).ceil();
var resmap = smap.remap([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],
[0,0,0,0,0,0,0,0,0,45,55,60,65,70,75,80,85,90,95,100]); //Reclassified mean sand content
Map.addLayer(savg.clip(prov), null, 'Soil sand content', false)
var gtsavg = savg.updateMask(savg.gte(45)) //sand content greater than 45%
var sandvis= {min: 0, max: 100, palette: ['fbff00','000000']};
var n = ee.Image("OpenLandMap/SOL/SOL_WATERCONTENT-33KPA_USDA-4B1C_M/v01")
var navg = n.reduce(ee.Reducer.mean()) //soil water content
Map.addLayer(navg.clip(prov), null, 'Soil water content', false)
var xx = resmap.add(navg) //Soil water content percentage + Reclassified soil sand content percentage
Map.addLayer(xx.clip(prov), null, 'Sand + Water Content', false)
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="41.9925" label="41.9925" />' +
'<ColorMapEntry color="#FFFF40" quantity="78.9925 " label="78.9925 " />' +
'<ColorMapEntry color="#FFBF40" quantity="115.985" label="115.985" />' +
'<ColorMapEntry color="#EC4040" quantity="152.97" label="152.97" />' +
'</ColorMap>' +
'</RasterSymbolizer>';
var sarbuff = sesar.map(bufferBy(25000*4))
Map.addLayer(xx.sldStyle(intervals).clip(prov), {}, 'Susceptibility Categorization');
Map.addLayer(gtsavg.clip(prov), sandvis, 'Soil with sand content >45%')
Map.centerObject(prov, 7)
So, if you run the script it will show you two layers of active map. ‘Soil with sand content >45%’ and ‘Susceptibility Categorization’.
Based on var xx = resmap.add(navg), when I clicked the Google Earth Engine’s inspector in the darker area (area with soil sand content >45%), I expected the Soil sand content percentage to be added to Soil water content percentage, which the total percentage will be shown in Sand + Water Content, and thus the total percentage then will be matched to the right color, accordingly, based on the colors on these lines:
'<ColorMapEntry color="#0CE84A" quantity="41.9925" label="41.9925" />' +
'<ColorMapEntry color="#FFFF40" quantity="78.9925 " label="78.9925 " />' +
'<ColorMapEntry color="#FFBF40" quantity="115.985" label="115.985" />' +
'<ColorMapEntry color="#EC4040" quantity="152.97" label="152.97" />' +
Unfortunately, that didn’t happen. The Sand + Water Content will be the same percentage with Soil water content, despite the Soil sand content percentage is above 45%. So, what did I do wrong? And, any idea to fix it?
In the var resmap = smap.remap()
line all of the scaled soil sand content (smap
) pixels are being set as 0, so when you add the "remapped" soil sand content (resmap
) layer to the water content (navg
) layer the result is equal to water content (navg
).
I don't understand the scaling line var smap = savg.divide(20).ceil();
, the greatest value that is produced is 4 (there is almost no range and precision is drastically reduced):
var maxSmap = smap.reduceRegion({
reducer: ee.Reducer.max(),
geometry: prov,
scale: smap.projection().nominalScale(),
bestEffort: true,
maxPixels: 1e13
})
print(maxSmap)
which, according to your remapping lists, values 1, 2, 3 are all set to 0. I think you need to reconsider the scaling and the remapping values.
Inspect these two map layers to see the effect of the scaling:
Map.addLayer(smap.clip(prov), null, 'Soil sand content', true)
Map.addLayer(resmap.clip(prov), null, 'Soil sand content - remap', true)
Answered by Justin Braaten on October 1, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP