Geographic Information Systems Asked on April 8, 2021
The below code computes area elevation relationship by iteration algorithm. But when the interval sets to 0.5 shows same area values in a row(like the below picture).
code link: https://code.earthengine.google.com/d6fea46bec579534464dc7e9d58e4290
Map.centerObject(geometry);
var dem = ee.Image("JAXA/ALOS/AW3D30/V2_2").clip(geometry).select('AVE_DSM');
Map.addLayer(dem,[],'DEM',false);
var demMin = ee.Number(dem.reduceRegion(ee.Reducer.min(), geometry, 250).get('AVE_DSM')).float();
var demMax = ee.Number(dem.reduceRegion(ee.Reducer.mean(), geometry, 250).get('AVE_DSM')).float();
print('minElevation:',demMin);
print('maxElevation:',demMax);
//////////////////////////////// area elevation
var interval = ee.Number(0.5);
var waterlevel = ee.List.sequence(demMin,demMax,interval);
var calcArea = function(level,list){
var inundated = dem.lte(ee.Number(level));
var area = inundated.multiply(30.0).multiply(30.0);
var totalarea = area.reduceRegion(ee.Reducer.sum(), geometry);
return ee.List(list).add(totalarea.get('AVE_DSM'));
};
var first = ee.List([]);
var AREA = ee.List(waterlevel.iterate(calcArea, first));
print('Area Estimated:',AREA)
But when the interval sets to 0.5 shows same area values in a row(like the below picture).
The bands have integer values: if you print(dem.bandTypes());
then you can see the type reported as AVE_DSM: signed int16
. Therefore, any step smaller than 1.0 will sometimes not differ from the previous step. There simply isn't any more resolution in the data.
You didn't ask about performance, but a note: in general, iterate
is not very efficient, and should be avoided whenever possible. In this case, there is no need at all to use iterate
because each value computed does not depend on the previous value(s); map
suffices. Here is your code modified to use map
:
var calcArea = function(level) {
var inundated = dem.lte(ee.Number(level));
var area = inundated.multiply(30.0).multiply(30.0);
var totalarea = area.reduceRegion(ee.Reducer.sum(), geometry);
return totalarea.get('AVE_DSM');
};
var AREA = waterlevel.map(calcArea);
Correct answer by Kevin Reid on April 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP