1. 程式人生 > 其它 >GEE學習筆記2:載入Landsat8 和Sentinel影像資料

GEE學習筆記2:載入Landsat8 和Sentinel影像資料

技術標籤:GEEgoogle earthjavascript

從GEE資料集匯入的資料

邊界載入

//hlj1為匯入的shp資料
var roi = hlj1;
Map.centerObject(roi,5);
var empty = ee.Image().toByte();
var outline = empty.paint({
 featureCollection:roi,  // 篩選的colletion
 color:0, //顏色透明
 width:3  //邊界寬度
});
//繪製紅色邊界
Map.addLayer(outline, {palette: "ff0000"}, "outline");
//定義時間節點
var startdate = ee.Date.fromYMD(2016,5,1);
var enddate = ee.Date.fromYMD(2016,10,1);

載入Sentinel 1資料

//s1為從GEE 資料集匯入的Sentinel 1資料
var Sentinel1_VV =  s1.filterBounds(roi)
           .filterDate(startdate, enddate)
           .filter(ee.Filter.eq('instrumentMode', 'IW'))
           .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
           .select('VV')
           .median();
​
var Sentinel1_VH =  s1.filterBounds(roi)
           .filterDate(startdate, enddate)
           .filter(ee.Filter.eq('instrumentMode', 'IW'))
           .filter(ee.Filter.listContains('transmitterReceiverPolarisation',                       'VH'))
          
           .select('VH')
           .median();

載入Sentinel 2

//去雲函式
var cloudfunction_ST2 = function(image){
  //use add the cloud likelihood band to the image
  var quality = image.select("QA60").unmask();
  //get pixels above the threshold
  var cloud01 = quality.gt(0);
  //create a mask from high likelihood pixels
  var cloudmask = image.mask().and(cloud01.not());
  //mask those pixels from the image
  return image.updateMask(cloudmask);
};
//s2為從GEE 資料集匯入的Sentinel 2資料
var Sentinel2 = s2.filterBounds(roi)
         .filterDate(startdate, enddate)
         .map(cloudfunction_ST2)
         .median();

載入Landsat 8

//去雲 
function maskL8sr(image) {
  var cloudShadowBitMask = (1 << 3);
  var cloudsBitMask = (1 << 5);
  var qa = image.select('pixel_qa');
  var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
         .and(qa.bitwiseAnd(cloudsBitMask).eq(0));
  return image.updateMask(mask);
}
//L8為從GEE 資料集匯入的Landsat 8資料
var landsat8Image =L8.filterBounds(roi)
           .filterDate(startdate, enddate)
          .median();