Google Earth Engine(GEE)——利用sentinel-2数据
首先針對感興趣的時間段和位置過濾動態(tài)世界集合sentinel-2土地分類數(shù)據(jù)集。在這里,我們要繪制一年中該位置的變化圖表。因此,我們應(yīng)用過濾器來選擇在感興趣的時間段內(nèi)在該區(qū)域收集的圖像。最后,我們選擇所有類別的概率波段。
本次用到的函數(shù):
ui.Chart.image.series(imageCollection, region, reducer, scale, xProperty)
從一個ImageCollection生成一個圖表。繪制一個區(qū)域內(nèi)每個波段在不同圖像中的衍生值。通常是一個時間序列。
X軸。圖像,用xProperty值標(biāo)記。
Y-軸。波段值。
系列。波段名稱。
返回一個圖表。
參數(shù)。
imageCollection(圖像集合)。
一個包含數(shù)據(jù)的ImageCollection,將被包含在圖表中。
region (Feature|FeatureCollection|Geometry)。
要減少的區(qū)域。
reducer(還原器,可選)。
用于生成Y軸數(shù)值的還原器。必須返回一個單一的值。默認(rèn)為ee.Reducer.mean()。
scale (Number, optional):
與還原器一起使用的刻度,單位是米。
xProperty(字符串,可選)。
作為X軸上每個圖像的標(biāo)簽的屬性。默認(rèn)為'system:time_start'。
返回: ui.Chart
代碼:
// 隨時間變化的類別概率圖表 //定義研究區(qū)var table = ee.FeatureCollection("users/bqt2000204051/beijing"); var geometry = table.geometry(); Map.centerObject(geometry, 10);// 對感興趣的時間段和地點的動態(tài)世界集合進(jìn)行過濾。 var startDate = '2020-01-01'; var endDate = '2021-01-01';var dw = ee.ImageCollection('GOOGLE/DYNAMICWORLD/V1').filterDate(startDate, endDate).filterBounds(geometry);//選擇所有波段 var probabilityBands = ['water', 'trees', 'grass', 'flooded_vegetation', 'crops','shrub_and_scrub', 'built', 'bare', 'snow_and_ice'];// 選擇所有的概率段。 var dwTimeSeries = dw.select(probabilityBands);// 繪制北京市的時間序列。 var chart = ui.Chart.image.series({imageCollection: dwTimeSeries,region: geometry,scale: 1000,//maxPixels:1e13這里設(shè)定最大像素值是無法實現(xiàn)的,減小研究區(qū)或者設(shè)法放款scale }); print(chart);// 重新定義我們的chart,然后我們對比查看兩者的區(qū)別// 一個輔助函數(shù),用于為圖表中的9個系列中的每個系列設(shè)置標(biāo)簽、顏色和樣式屬性。 function lineStyle(label, color) {var style_dict = {labelInLegend: label,color: color,lineWidth: 2, pointSize: 3};return style_dict; }// 我們現(xiàn)在創(chuàng)建圖表,用配置選項的字典調(diào)用setOptions。 var chart = ui.Chart.image.series({imageCollection: dwTimeSeries,region: geometry,scale: 1000,}).setOptions({vAxis: {title: 'Class probabilities',viewWindow: {min: 0, max: 1}},interpolateNulls: true,series: {0: lineStyle('Bare', '#A59B8F'),1: lineStyle('Built', '#C4281B'),2: lineStyle('Crops', '#E49635'),3: lineStyle('Flooded_vegetation', '#7A87C6'),4: lineStyle('Grass', '#88B053'),5: lineStyle('Shrub and scrub', '#DFC35A'),6: lineStyle('Snow and ice', '#B39FE1'),7: lineStyle('Trees', '#397D49'),8: lineStyle('Water', '#419BDF')} }); print(chart);原始的時間序列:?
?這個沒有設(shè)置title和y軸的標(biāo)題
?
總結(jié)
以上是生活随笔為你收集整理的Google Earth Engine(GEE)——利用sentinel-2数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Redis集群搭建(基于6.2.6版本)
- 下一篇: MAP 地图