按点提取像素值并转换为Google Earth Engine中的表格 [英] Extract pixel values by points and convert to a table in Google Earth Engine

查看:790
本文介绍了按点提取像素值并转换为Google Earth Engine中的表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行一个项目,该项目将火灾严重程度的现场测量结果与火灾前后的Landsat影像得出的波段值和光谱指数相关联.我目前正在使用Google Earth Engine从Landsat图像集合中提取表面反射率值.我使用的方法将我的现场站点位置(点数据)导入为特征集合,并使用getRegion函数从每个点的Landsat图像集合中提取波段值.下面提供了代码:

I am undertaking a project that is relating field measurements of fire severity to band values and spectral indices derived from Landsat imagery before and after the fire. I am currently using Google Earth Engine to extract surface reflectance values from a collection of Landsat images. The approach I am using imports my field site locations (point data) as a feature collection and uses the getRegion function to extract band values from a Landsat image collection at each point. The code is provided below:

//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);

我的问题是如何将生成的样本"变量(列表列表)转换为可导出到Google Drive的表?还是有更好的方法通过Google Earth Engine中的点提取图像数据?

My question is how can I convert the resulting 'sample' variable (a list of lists) to a table that can be exported to google drive? Or is there a better approach to extract image data by points in Google Earth Engine?

我是Google Earth Engine和Java编程语言的新手,所以对于此问题的答案是否显而易见,我深表歉意.我花了很多时间试图找到解决这个问题的方法,但我感觉自己一无所获.

I am new to Google Earth Engine and the Java programming language, so I apologise if the answer to this question is obvious. I have spent a lot of time trying to find a solution to this problem and I feel like I am getting nowhere.

谢谢

卢克

推荐答案

我无法访问您的融合表,因此我为该示例添加了一些随机点. 我很确定还有其他方法可以做到. GEE具有许多功能,有时使用起来有些棘手.这就是我的方式:

I can't get access to your fusion table, so I made up some random points for the example. I'm pretty sure there is other ways to do it. GEE has many functions and some times they are a bit tricky to use. This would be my way:

// 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")

这篇关于按点提取像素值并转换为Google Earth Engine中的表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆