使用Google Earth Engine(一):提取下载MODIS、Landsat点数据

来源:互联网 发布:天音淘宝复制大师官网 编辑:程序博客网 时间:2024/05/19 13:27

    现在可以使用Google Earth Engine 快捷的提取MODIS、Landsat等产品的点(或区域)数据到自己的Google Drive下载。PS:GEE可以做全球尺度长时间序列的数据分析出图等,将来必是地球科学领域的大杀器。这里下载数据不是仅运行下面代码就行,还需要注意两点:

1)那么如何找到数据集呢?在搜索栏输入产品名,便可快速定位到产品,点击产品名右侧的import可以导入产品数据集。点击代码窗体里导入产品数据集右侧的按钮可以查看导入的代码。

2)运行代码后会产生一个处理任务,需要在Tasks里找到任务并运行。


    大杀器的链接:https://code.earthengine.google.com/

    附一段提取MO09GA反射率产品点数据的示例代码:

代码参考:rodrigo-e-principe 在stackoverflow上的回答。

extract-pixel-values-by-points-and-convert-to-a-table-in-google-earth-engine

exporting-all-images-in-a-google-earth-engine-image-collection-google-earth-eng

// code goes here

// define point or point feature colection, format [longitude, latitude]

var pt1 = ee.Geometry.Point([24.9478,-17.8756]);

// For multi-point, Create a multi-part feature.// var multiPoint = ee.Geometry.MultiPoint([[-121.68, 39.91], [-97.38, 40.34]]);

// import dataset filt with time, andgeometry (point)

var imageCollection =ee.ImageCollection("MODIS/006/MOD09GA")

 .filterDate('2014-01-01', '2015-01-03')

 .filterBounds(pt1);

 

// Empty Collection to fill

var ft = ee.FeatureCollection(ee.List([]))

 

var fill = function(img, ini) {

  //type cast

  varinift = ee.FeatureCollection(ini)

 

  //gets the values for the points in the current img

  varft2 = img.reduceRegions(pt1, ee.Reducer.first(),500)

 

  //gets the date of the img

  vardate = img.date().format()

 

  //writes the date in each feature

  varft3 = ft2.map(function(f){return f.set("date", date)})

 

  //merges the FeatureCollections

 return inift.merge(ft3)

}

 

// Iterates over the ImageCollection

var newft =ee.FeatureCollection(imageCollection.iterate(fill, ft))

// Export

Export.table.toDrive({collection:newft,

description:'MOD09GA_point'})