Google Earth engine grid algebra and band calculation for NDVI

Time:2022-5-20

  this article mainly focuses onGEEMediumGrid algebra and band calculationThe operation is introduced. This article is the sixth in a series of teaching articles on Google Earth engine (GEE). MoreGEEPlease refer to the column:Gee learning and Applicationhttps://blog.csdn.net/zhebushibiaoshifu/category_11081040.html)。

  first, according to part II GeeTeaching bloghttps://blog.csdn.net/zhebushibiaoshifu/article/details/117296956)In the content, we willLandsat 8 Collection 1 Tier 1Atmospheric apparent reflectanceTOA ReflectanceImport the product into Gee and rename it. Next, also according to the second GeeTeaching bloghttps://blog.csdn.net/zhebushibiaoshifu/article/details/117296956)Content in, willLandsat 8 Collection 1 Tier 1Atmospheric apparent reflectanceTOA ReflectanceThe product is selected according to the time (you can choose the specific time range arbitrarily), and the average value within the corresponding time range is obtained; At the same time, the layer after the above operation will be displayed in the map.

var landsat_202006=landsat_8.filterDate('2020-06-01','2020-06-30').mean();
Map.addLayer(landsat_202006,{},"Landsat");
Google Earth engine grid algebra and band calculation for NDVI

  next, let’s start grid computing. In part 5 GeeTeaching bloghttps://blog.csdn.net/zhebushibiaoshifu/article/details/118909637)In, we usenormalizedDifference()Function calculationNDVILayer; In this paper, we try to calculate the band manuallyNDVILayer, the specific code is as follows. Among them,.select()Indicates that the corresponding band is selected from the remote sensing image,.subtract()The function represents the subtraction operation between bands; Similarly,.add()The function represents the addition operation,.divide()Indicates a division operation.

var band_4=landsat_202006.select('B4');
var band_5=landsat_202006.select('B5');
var numerator=band_5.subtract(band_4);
var denominator=band_5.add(band_4);
var NDVI=numerator.divide(denominator);
Map.addLayer(NDVI,{},"NDVI");

  run the above code and you can seeNDVIThe layer has been generated.

Google Earth engine grid algebra and band calculation for NDVI

  here’s another point to note: in the most primitiveLandsat 8 Collection 1 Tier 1Atmospheric apparent reflectanceTOA ReflectanceProduct (data type:ee.ImageCollection)After selecting according to the time and obtaining the average value within the corresponding time range (the data type isee.Image), each band of remote sensing image can participate in the calculation. in other words,.subtract()These band operation functions are only foree.ImageValid data; And ifee.ImageCollectionAnd other data types need to participate in band calculation, as well as mapping and other operations.

  in addition, we can also follow Part IV geeTeaching bloghttps://blog.csdn.net/zhebushibiaoshifu/article/details/117573181)Medium method, rightNDVIThe layer is manually visualized and configured, and the configuration is embedded into the code, so as to realize the result of each code runNDVIThe layer visualization settings are consistent.

Google Earth engine grid algebra and band calculation for NDVI

The specific codes are as follows:

Map.addLayer(NDVI,{min:[-0.2111],max:[0.6778],palette:["ff2a08","fff810","56ff10","1889ff","e510ff"]},"NDVI");

  you can see it after runningNDVIThe layer already has the default visualization configuration~

Google Earth engine grid algebra and band calculation for NDVI