亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 Google Earth Engine 上的單個圖中將時間序列數據集與不同時間步長結合起來

如何在 Google Earth Engine 上的單個圖中將時間序列數據集與不同時間步長結合起來

泛舟湖上清波郎朗 2023-07-20 16:29:16
我目前正在嘗試在同一張圖表中繪制每月和每年土壤濕度的時間序列。我有一個 ImageCollection,其中包含 480 張圖像(每月一張),另一個 ImageCollection 包含 40 張圖像(每年一張)。我可以單獨繪制它們,但我還沒有找到將兩個圖堆疊在一個圖表中的方法。我查找的一些選項是(a)預先執行innerJoin(),但這會將每月收集的圖像從480張圖像縮減到40張,或者(b)用Na填充年度收集中的空白(類似于用pandas填充Na) ,但我想不出辦法來做到這一點。這是代碼示例:// --- GLOBALS ---var dateStart = ee.Date('1980-01-01'); var dateEnd = ee.Date('2019-12-31');var scale = 1000;var studyArea = ee.FeatureCollection('TIGER/2018/States').filterMetadata('NAME', 'equals', 'Nevada');var monthlySoil = ee.ImageCollection('IDAHO_EPSCOR/TERRACLIMATE') // Load data                .filter(ee.Filter.date(dateStart, dateEnd))                .select('soil');// --- TIME SERIES ---// Create list of dates for time seriesvar dateListYearly = ee.List.sequence(0,dateEnd.difference(dateStart,'year').round(),1);var makeDateListYearly = function(n) {return dateStart.advance(n,'year')};dateListYearly = dateListYearly.map(makeDateListYearly);// Yearly datavar yearlySoil = [];yearlySoil = dateListYearly.map(function(d){ // Resample yearly  var start = ee.Date(d);  var end = ee.Date(d).advance(1,'year');  var dateRange = ee.DateRange(start,end);  var yearlySoilInter = monthlySoil                      .filterDate(dateRange)                      .mean()                      .clip(studyArea)                      .rename('Yearly');  return(yearlySoilInter.set('system:time_start', start.millis())); // Add time band});yearlySoil = ee.ImageCollection(yearlySoil);// --- PLOT ---var options1 = { // Monthly   title: 'SM Monthly',  fontSize: 12,  hAxis: {title: 'Date'},  vAxis: {title: 'SM (mm)'},  series: {0: {color: 'red'}}};print(ui.Chart.image.series(monthlySoil, studyArea, ee.Reducer.mean(), scale).setOptions(options1));var options2 = { // Yearly   title: 'SM yearly',  fontSize: 12,  hAxis: {title: 'Date'},  vAxis: {title: 'SM (mm)'},  series: {0: {color: 'blue'}}};和鏈接:https://code.earthengine.google.com/1443f7796cd2d1527e4ca9fec145f4b7
查看完整描述

1 回答

?
臨摹微笑

TA貢獻1982條經驗 獲得超2個贊

與您用 NA 填充間隙的想法類似,我向每個集合添加了一個空帶,以匹配其他集合中的相應帶。然后我合并了這些集合并制作了一個圖表。


s2sr = s2sr.filterBounds(roi).filter(ee.Filter.calendarRange(2020, 2020, 'year'))

l8sr = l8sr.filterBounds(roi).filter(ee.Filter.calendarRange(2020, 2020, 'year'))


// compute some bands to add to each collection

var addS2Bands = function(image){

  var s2nd = image.normalizedDifference(['B4','B3']).rename('s2_nd')

  var l8nd = ee.Image().rename('l8_nd') // must add an empty band for select() to work on all images

  return image.addBands(s2nd).addBands(l8nd)

}

var addL8Bands = function(image){

  var l8nd = image.normalizedDifference(['B4','B3']).rename('l8_nd')

  var s2nd = ee.Image().rename('s2_nd')

  return image.addBands(l8nd).addBands(s2nd)

}

l8sr = l8sr.map(addL8Bands)

s2sr = s2sr.map(addS2Bands)



// merge the collections

var merged = l8sr.merge(s2sr).select(['l8_nd', 's2_nd'])


// plot the collection

var chart = ui.Chart.image.series({

  imageCollection: merged,

  region: roi,

  reducer: ee.Reducer.mean(),

  scale: 30

})

print(chart)

https://code.earthengine.google.com/?scriptPath=users%2Fcaseyengstrom%2Freprex%3AuiChartMultiCollection


查看完整回答
反對 回復 2023-07-20
  • 1 回答
  • 0 關注
  • 163 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號