GEE—About the problems in the RSEI ecological remote sensing index Layer error: Image.rename: The number of names (1) must match the number of..

The problem that arises:

I am just getting in touch with GEE. I read your article "Google Earth Engine - Landsat 1985-2020 Ecological Remote Sensing Index RESI Calculation" and quoted the code you shared. During the operation, it prompts "RSEI2004: Layer error: Image.rename: The number of names (1) must match the number of bands (5)", I would like to ask you for advice. Because I'm new to it, I can't understand a lot of problems in the running of the code, so please enlighten me! At the same time, I also want to ask you if there is any suitable course recommendation for Xiaobai to study by himself. Here you can go to my column This Star Bright_GEE Dataset Column, GEE Tutorial Training, Google Earth Engine-CSDN Blog , "GEE Tutorial Training"\ "Google earth engine", "gee case analysis" and "gee python" you can choose according to your own situation

In the future, relevant tutorial videos will be uploaded, and corresponding new books will be published, so I hope everyone will continue to pay attention here.

RSEI2004: Layer error: Image.rename: The number of names (1) must match the number of bands (5)”,

 

The main reason for the above problem is from this blog I wrote before, about the code for calculating RSEI year by year, the original blog address:

Google Earth Engine - Landsat 1985-2020 ecological remote sensing index RESI calculation - Programmer Sought

The RSEI Ecological Remote Sensing Index is a remote sensing index used to assess ecological quality. The index mainly extracts information such as land use type, vegetation coverage, land form, land surface cover, and land use mode from remote sensing images. Through comprehensive analysis and calculation of these information, an index value reflecting the quality of the ecological environment is obtained. Assess the ecological environment quality of a certain area. The index can be used in fields such as ecological environment monitoring, ecological protection and ecological restoration.

Original code code:

// var roi = 
//     /* color: #d63000 */
//     /* displayProperties: [
//       {
//         "type": "rectangle"
//       }
//     ] */
//     ee.Geometry.Polygon(
//         [[[105.55104505173978, 34.27794089351641],
//           [105.55104505173978, 33.54856067523731],
//           [106.51784192673978, 33.54856067523731],
//           [106.51784192673978, 34.27794089351641]]], null, false);
 
function Interpol(imgcoll, timeBandName)
{
  // length
  var colsize = imgcoll.size();
  var bandNames = imgcoll.first().bandNames();
  // make sure first and last NonNull
  var firstImg = imgcoll.reduce(ee.Reducer.firstNonNull()).rename(bandNames); // yuan
  var lastImg = imgcoll.reduce(ee.Reducer.lastNonNull()).rename(bandNames);  //  jin
  var imgList = imgcoll.toList(colsize);
  // reset imglist
  var B = imgList.slice(1,-1);
  var A = ee.Image(imgList.get(0));
  var C = ee.Image(imgList.get(-1));
  firstImg = firstImg.set({'system:time_start':A.get('system:time_start')});
                  //  .set({'user:index':A.get('user:index')});
  lastImg = lastImg.set({'system:time_start':C.get('system:time_start')});
                  //  .set({'user:index':C.get('user:index')});
  var D = B.insert(0, firstImg).add(lastImg);
  var D_imgcol = ee.ImageCollection(D);
  // mask imgcol
  var imgcollmask = imgcoll.map(function(img)
  {
    img = img.updateMask(img.select(0).mask());
    return img;
  });
  var D_mask = imgcollmask.toList(colsize);
  var maskBandNames = imgcollmask.first().bandNames();
  // interpol
  var imgcoll_List_Interpol = ee.List.sequence(1, colsize.subtract(2)).map(function(i)
  {
    i = ee.Number(i);
    var pre= ee.ImageCollection(D_mask.slice(0,i.add(1))).reduce(ee.Reducer.lastNonNull());
    var cur= D.get(i);
    var next=ee.ImageCollection(D_mask.slice(i,-1)).reduce(ee.Reducer.firstNonNull());
    pre=ee.Image(pre).rena

Guess you like

Origin blog.csdn.net/qq_31988139/article/details/132124508