I extracted daytime and nighttime land surface temperatures (LST) of my 13 points from the Modis MOD11A1 dataset using Google Earth Engine (GGE). For this task I modified the following code:
var Bhagirathi = ee.FeatureCollection("users/Vineeth_Russell/NRSC_Bhagirathi_shp");
//Terra and Aqua Day time LST Daily Global 1km
var day_terra = ee.ImageCollection("MODIS/006/MOD11A1")
.filter(ee.Filter.date('2000-03-05', '2010-01-01'))
.select('LST_Day_1km','QC_Day');
//Terra and Aqua Night time LST Daily Global 1km
var night_terra = ee.ImageCollection("MODIS/006/MOD11A1")
.filter(ee.Filter.date('2000-03-05', '2010-01-01'))
.select('LST_Night_1km','QC_Night');
//create mask to extract only highest quality day band data
var filterDay = function(image){
var qa = image.select('QC_Day');
var bitMask2 = 1 << 2;
var mask = qa.bitwiseAnd(bitMask2).eq(0);
return image.updateMask(mask);
};
//create mask to extract only highest quality night band data
var filterNight = function(image){
var qa = image.select('QC_Night');
var bitMask2 = 1 << 2;
var mask = qa.bitwiseAnd(bitMask2).eq(0);
return image.updateMask(mask);
};
//apply mask to image collection
var lst_d_terra = day_terra.map(filterDay);
var lst_n_terra = night_terra.map(filterNight);
//Scale to Kelvin and convert to Celsius, set image acquisition time (Terra Day-time)
lst_d_terra = lst_d_terra.map(function(img) {
return img.select('LST_Day_1km')
.multiply(0.02)
.subtract(273.15)
.copyProperties(img, ['system:time_start','system:time_end']);
});
//Scale to Kelvin and convert to Celsius, set image acquisition time (Terra Night-time)
lst_n_terra = lst_n_terra.map(function(img) {
return img.select('LST_Night_1km')
.multiply(0.02)
.subtract(273.15)
.copyProperties(img, ['system:time_start','system:time_end']);
});
//Charting Terra Day-time LST over Bhagirathi
print(Chart.image.series(lst_d_terra, Bhagirathi,ee.Reducer.mean(),1000).setOptions({
title: "Time Series of MODIS Terra Daily Day-time LST across Bhagirathi",
hAxis: {
title: "Time Period",
titleTextStyle: {italic: false, bold: true}
},
vAxis: {
title: "LST",
titleTextStyle: {italic: false, bold: true}
},
colors: ["Red"]
}));
//Charting Terra Night-time LST over Bhagirathi
print(Chart.image.series(lst_n_terra, Bhagirathi,ee.Reducer.mean(),1000).setOptions({
title: "Time Series of MODIS Terra Daily Night-time LST across Bhagirathi",
hAxis: {
title: "Time Period",
titleTextStyle: {italic: false, bold: true}
},
vAxis: {
title: "LST",
titleTextStyle: {italic: false, bold: true}
},
colors: ["Blue"]
}));
and try to export the daytime values regarding the code stated below.
var yearly = ee.ImageCollection('JRC/GSW1_0/YearlyHistory');
// function to map over the FeatureCollection
var mapfunc = function(feat) {
// get feature geometry
var geom = feat.geometry()
// function to iterate over the yearly ImageCollection
// the initial object for the iteration is the feature
var addProp = function(img, f) {
// cast Feature
var newf = ee.Feature(f)
// get date as string
var date = img.date().format()
// extract the value (first) of 'waterClass' in the feature
var value = img.reduceRegion(ee.Reducer.first(), geom, 30).get('waterClass')
// if the value is not null, set the values as a property of the feature. The name of the property will be the date
return ee.Feature(ee.Algorithms.If(value,
newf.set(date, ee.String(value)),
newf.set(date, ee.String('No data'))))
}
var newfeat = ee.Feature(yearly.iterate(addProp, feat))
return newfeat
};
var newft = fg_points.map(mapfunc);
// Export
Export.table.toDrive(newft,
"export_Points",
"export_Points",
"export_Points");
So far this worked well for extracting and exporting LST values.
I also wanted to extract the observation time for day and night LST values. However, I can not manage to extract and export the observation times to my Google drive in CSV format. I haven't used MODIS MOD11A1 data before and I'm pretty novice to Google Earth Engine.
Here is my GRE code.
Edit1:
Actually, in Modis MOD11A1 dataset, there is a band called Day_view_time and Night_view_time. When I copy and pasted the coordinates and modified @xunilk 's code it worked both for LST and observation time values. However, I could not perform it with a table instead of FeatureCollection. How can I export the values to my Google Drive if I import my points as table using assets?
Here is my updated code.