GEE: Extract time series data of multiple points and save it in csv format (take NDVI as an example)

In the past few days, I have done some work to extract a point time series. The first code in this article records the code for extracting the NDVI value time series of three points , and records the method of saving the result in csv format to the local. The second code records printing a time series of a point in the console in the form of a line chart.


1. Input point coordinates

Enter data for three points.

2. Results display

The LAI time series of each point is saved in the csv table, as shown in the figure below. 'Index' corresponds to the index of the point, and the list of points has been printed out in the code, which can be retrieved corresponding to the index. Each column is time.

3. Code implementation

The main code is shown below and can be run directly.

//将点坐标转换成FeatureCollection,这里添加三个点
var col=ee.List([[116.379, 39.98], [116.116, 39.896], [116.5393, 39.9414]]);
var point = ee.FeatureCollection(ee.Geometry.MultiPoint(col));
print("point", point)

//加载矢量图层
Map.centerObject(point);
Map.addLayer(point, {
    
    }, 'geometry')

//影像集合筛选
var dataset = ee.ImageCollection("MODIS/061/MOD13A2")
                .filterDate('2004-01-01', '2014-12-31')
                .select('NDVI')
                .toBands()

//统计其给出的样本点的NDVI
var pixelValues = dataset.sampleRegions({
    
    
			    collection: point,
			    scale: 30, //每个点的缓冲区大小
});

print("NDVIValue", pixelValues)

//将影像导出
Export.table.toDrive({
    
    
			    collection: pixelValues,
			    description:"NDVIPointsTimeSerises30m",
			    folder: "NDVITS",
			    fileFormat: "CSV"
});

4. Print the time series to the console

The red arrow button downloads time series data to, csv.

The code looks like this:

var point = ee.Geometry.Point([116.379, 39.98]);

//影像集合筛选
var dataset = ee.ImageCollection("MODIS/061/MOD13A2")
                .filterDate('2004-01-01', '2014-12-31')
                .select('NDVI')
                
// 创建折线图
var chart = ui.Chart.image.series({
    
    
			    imageCollection: dataset.select('NDVI'),
			    region: point,
			    //reducer: ee.Reducer.max(),
			    scale: 500
}).setOptions({
    
    title: 'NDVI'});

// 可视化折线图
print(chart);

5. Code link

Time series of NDVI values ​​​​for three points: https://code.earthengine.google.com/cb661539564f4704db2a5acb3f2504ab?noload=true
Print time series of one point to the console: https://code.earthengine.google.com/9c232090cc07e170514c50ae0d379d3f? noload=true

Guess you like

Origin blog.csdn.net/qq_35591253/article/details/128008255#comments_27878630