I am quite new to both Google Earth Engine and JavaScript. I have an LST image for all the regions. I want to extract LST pixels from east to west and from north to south around POI. Where the black line indicates in the figure. (in the range of 5-10 km)
My goal is to draw the following graph with the extracted pixels.
How do I do it using the Google Earth Engine JavaScript API.
Here is my code so far.
Map.centerObject(py_point, 9.5);
// Select Landsat 8 TOA image (CLOUD_COVER_LAND is less than 5%)
var col_l8 = ee.ImageCollection(l8_TOA
.filterBounds(py_point)
.aside(print)
.filterDate('2019-01-01', '2019-12-31')
.filterMetadata('CLOUD_COVER', 'less_than', 5)
.select(['B4', 'B5', 'B10'])); // 2019-05, 2019-09
print(col_l8, 'l8_2019');
// Define a function that will add an NDVI band to a Landsat 8 image.
var addNDVI = function(image) {
var NDVI = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
return image.addBands(NDVI);
};
// Add an NDVI band
var ndviAdded_2019 = ee.ImageCollection(col_l8
.map(addNDVI));
print(ndviAdded_2019.first(), 'ndvi_2019');
// Emissivity
var addEM = function emissivity(image){
var ndvi = image.select('NDVI');
var e1 = ee.Number(0.995);
var e2 = ee.Number(0.97);
var e3 = image.expression(
'1.0094 + 0.047*(log(NDVI))', {
'NDVI': image.select(['NDVI'])
});
var e4 = ee.Number(0.99);
var emis1 = ee.Image(ndvi.lt(-0.185)).multiply(e1)
.rename('emis1');
var emis2 = ee.Image(ndvi.gte(-0.185)).and(ndvi.lt(0.157)).multiply(e2)
.rename('emis2');
var emis3 = ee.Image(ndvi.gte(0.157)).and(ndvi.lt(0.727)).multiply(e3)
.rename('emis3');
var emis4 = ee.Image(ndvi.gt(0.727)).multiply(e4)
.rename('emis4');
var em = image.expression(
'emis1 + emis2 + emis3 + emis4', {
'emis1': emis1.select('emis1'),
'emis2': emis2.select('emis2'),
'emis3': emis3.select('emis3'),
'emis4': emis4.select('emis4')
}).rename('EM');
return image.addBands(em);
}
// Add an EM band
var emAdded_2019 = ee.ImageCollection(ndviAdded_2019
.map(addEM));
print(emAdded_2019.first(), 'em_2019');
// Calculate Emissivity Pow
var addEmPow = function(image){
var pow = image.select('EM').pow(ee.Number(0.25))
.rename('EM_P');
return image.addBands(pow);
};
// Add an EM_P band
var empAdded_2019 = ee.ImageCollection(emAdded_2019
.map(addEmPow));
print(empAdded_2019.first(), 'emp_2019');
// Calculate LST(Celcius)
var addLST = function(image) {
var lst = image.expression(
'(T * EM_P) - 273.15', {
'T' : image.select(['B10']),
'EM_P': image.select(['EM_P'])}
).rename('LST');
return image.addBands(lst);
};
var lstAdded_2019 = ee.ImageCollection(empAdded_2019
.map(addLST));
print(lstAdded_2019.first(), 'lst_2019');
Map.addLayer(lstAdded_2019.first().select('LST'), {
min: 13,
max: 35,
palette: ['040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
'0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
'3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
'ff0000', 'de0101', 'c21301', 'a71001', '911003']
},
'LST');