Luk*_*ins 5 extract google-earth-engine
我正在进行一个项目,该项目将火灾严重程度的现场测量与从火灾前后的陆地卫星图像得出的波段值和光谱指数联系起来。我目前正在使用 Google Earth Engine 从陆地卫星图像集合中提取表面反射率值。我使用的方法将我的现场站点位置(点数据)导入为要素集合,并使用 getRegion 函数从每个点的 Landsat 图像集合中提取波段值。代码如下:
//IMPORT SAMPLE POINTS
var pts = ee.FeatureCollection('ft:1N9Hb01uCSHqGpz262K_f9VzWedxvTiV0g6tJwfw4');
//IMPORT LANDSAT IMAGE
var L82014pre = ee.ImageCollection('LANDSAT/LC8_SR') //Landsat 8 Surface reflectance
.filter(ee.Filter.eq('wrs_path', 94))
.filter(ee.Filter.eq('wrs_row', 86))
.filterDate(ee.Date.fromYMD(2013,12,13), ee.Date.fromYMD(2014,1,15))
//EXTRACT BY SAMPLE POINTS
var sample = L82014pre.getRegion(pts, 30);
Run Code Online (Sandbox Code Playgroud)
我的问题是如何将生成的“样本”变量(列表列表)转换为可以导出到谷歌驱动器的表?还是有更好的方法在Google Earth Engine中按点提取图像数据?
我是 Google Earth Engine 和 Java 编程语言的新手,所以如果这个问题的答案是显而易见的,我深表歉意。我花了很多时间试图找到这个问题的解决方案,但我觉得我一无所获。
谢谢你,
卢克
我无法访问您的融合表,因此我为示例添加了一些随机点。我很确定还有其他方法可以做到这一点。GEE 有很多功能,但有时使用起来有点棘手。这将是我的方式:
// As I can't access your FusionTable,
// I make random points and create a FeatureCollection
var p1 = ee.Geometry.Point([142.36083984375, -37.466138602344046])
var p2 = ee.Geometry.Point([143.23974609375, -37.04640889969956])
var pts = ee.FeatureCollection(ee.List([ee.Feature(p1),ee.Feature(p2)]))
//IMPORT LANDSAT IMAGE
var L82014pre = ee.ImageCollection('LANDSAT/LC8_SR') //Landsat 8 Surface reflectance
.filter(ee.Filter.eq('wrs_path', 94))
.filter(ee.Filter.eq('wrs_row', 86))
.filterDate(ee.Date.fromYMD(2013,12,13), ee.Date.fromYMD(2014,1,15))
// Empty Collection to fill
var ft = ee.FeatureCollection(ee.List([]))
var fill = function(img, ini) {
// type cast
var inift = ee.FeatureCollection(ini)
// gets the values for the points in the current img
var ft2 = img.reduceRegions(pts, ee.Reducer.first(),30)
// gets the date of the img
var date = img.date().format()
// writes the date in each feature
var ft3 = ft2.map(function(f){return f.set("date", date)})
// merges the FeatureCollections
return inift.merge(ft3)
}
// Iterates over the ImageCollection
var newft = ee.FeatureCollection(L82014pre.iterate(fill, ft))
// Export
Export.table.toDrive(newft,
"anyDescription",
"anyFolder",
"anyNameYouWant")
Run Code Online (Sandbox Code Playgroud)