问题:
ImageCollection (Error)
Error in map(ID=S1A_IW_GRDH_1SDV_20210305T102055_20210305T102120_036862_0455BC_F64C): Dictionary.get: Dictionary does not contain key: bucketMeans.
List (Error)
Collection.toList: Error in map(ID=S1A_IW_GRDH_1SDV_20210305T102055_20210305T102120_036862_0455BC_F64C): Dictionary.get: Dictionary does not contain key: bucketMeans.
问题主要应先更没有这个关键值,所以没办法获取,其实这里的本质我们刚开始看待程序的时候就是以为前面的function出了问题,但其实关键问题出在了影像筛选的过程中,这个筛选掉中因为我们多次筛选的时间结果不同给,所以会导致程序前面筛选的时间范围短,后面时间范围长,所以当你在执行程序的时候就出现了无法获取该指定影像的bucketmeans.
很多时候我们遇到这种问题一定要小心,往往这种问题不在于函数本身出错了。而在于我们应先该函数时间筛选的过程中是否有前后不一致的问题。
原有代码:
var imageVisParam = {"opacity":1,"bands":["VV"],"min":-25,"max":25,"gamma":1}, imageVisParam3 = {"opacity":1,"bands":["water"],"palette":["1d0701","3812ff"]}; // 计算面积是geometre,roi是buffer后的 var geometry=ee.FeatureCollection("users/smowry1/hbsk").filter(ee.Filter.eq("id",1)); var buffer=geometry.first().get("buffer"); var roi=geometry.geometry().buffer(buffer) var roiarea=ee.Number(roi.area()).divide(1000000) // var bufferarea=roi.area.divide(1000000) print(roi.area(),"buffer面") print(buffer); Map.centerObject(geometry, 8) function clip(img){ return img.clip(roi) } // 坡度校正 function slopeCorrection(image) { var imgGeom =roi var srtm = ee.Image('JAXA/ALOS/AW3D30/V2_2').select('AVE_DSM').clip(imgGeom) var sigma0Pow = ee.Image.constant(10).pow(image.divide(10.0)) // Article ( numbers relate to chapters) // 2.1.1 Radar geometry var theta_i = image.select('angle') var phi_i = ee.Terrain.aspect(theta_i) .reduceRegion(ee.Reducer.mean(), theta_i.get('system:footprint'), 1000) .get('aspect') // 2.1.2 Terrain geometry var alpha_s = ee.Terrain.slope(srtm).select('slope') var phi_s = ee.Terrain.aspect(srtm).select('aspect') // 2.1.3 Model geometry // reduce to 3 angle var phi_r = ee.Image.constant(phi_i).subtract(phi_s) // convert all to radians var phi_rRad = phi_r.multiply(Math.PI / 180); var alpha_sRad = alpha_s.multiply(Math.PI / 180); var theta_iRad = theta_i.multiply(Math.PI / 180); var ninetyRad = ee.Image.constant(90).multiply(Math.PI / 180); // slope steepness in range (eq. 2) var alpha_r = (alpha_sRad.tan().multiply(phi_rRad.cos())).atan(); // slope steepness in azimuth (eq 3) var alpha_az = (alpha_sRad.tan().multiply(phi_rRad.sin())).atan(); // local incidence angle (eq. 4) var theta_lia = (alpha_az.cos().multiply((theta_iRad.subtract(alpha_r)).cos())).acos(); var theta_liaDeg = theta_lia.multiply(180 / Math.PI); // 2.2 // Gamma_nought_flat var gamma0 = sigma0Pow.divide(theta_iRad.cos()) var gamma0dB = ee.Image.constant(10).multiply(gamma0.log10()); var ratio_1 = gamma0dB.select('VV').subtract(gamma0dB.select('VH')); // Volumetric Model var nominator = (ninetyRad.subtract(theta_iRad).add(alpha_r)).tan(); var denominator = (ninetyRad.subtract(theta_iRad)).tan(); var volModel = (nominator.divide(denominator)).abs(); // apply model var gamma0_Volume = gamma0.divide(volModel); var gamma0_VolumeDB = ee.Image.constant(10).multiply(gamma0_Volume.log10());