TransWikia.com

Extracting value of Landsat Band 8 at given location in Google Earth Engine

Geographic Information Systems Asked on May 17, 2021

I would like to have the value of the B8 of Landsat at a given location pt as an output but I keep on getting errors. I think I confused some values but cannot find the mistake. My code is below.

// LANDSAT 

// This example demonstrates the use of the Landsat 8 QA band to mask clouds.

// Function to mask clouds using the quality band of Landsat 8.var maskL8 = function(image) {
  var qa = image.select('BQA');
  /// Check that the cloud bit is off.
  // See https://www.usgs.gov/land-resources/nli/landsat/landsat-collection-1-level-1-quality-assessment-band
  var mask = qa.bitwiseAnd(1 << 4).eq(0);
  return image.updateMask(mask);
}

var start = '2019-06-01'
var finish = '2019-06-30'
var pt = ee.Geometry.Point([-49.31582, 69.56833]);
// Map the function over one year of Landsat 8 TOA data and take the median.
var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filterDate (start,finish)
.filterBounds(pt)
.map(maskL8)
.select ('B8');

Map.centerObject(pt, 16);



// B8 VALUE OF PT 

var myB8 = l8.select("B8"); 
print("myB8",myB8); 

var getB8 = function(image) {

  // Reducing region and getting value
  var value_B8 = ee.Image(image)
    .reduceRegion(ee.Reducer.first(), pt)
    .get('B8');

  return value_B8;
};

var count = myB8.size();

var B8_list = myB8.toList(count).map(getB8);

print("B8 list", B8_list);

var img = myB8.first();

Map.addLayer(img);
Map.addLayer(pt);

var allDates = myB8.aggregate_array('system:time_start');

var allDatesSimple = allDates.map(function procDates (ele) {
  
  return ee.Date(ele).format().slice(0,10);
  
});

var paired = allDatesSimple.zip(B8_list);

print (paired);

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP