使用 Google Earth Engine 使用栅格和矢量数据在像素 ID 级别构建表格数据集的最佳方法是什么?

What is the best method for building tabular dataset at pixel ID level with raster and vector data using Google Earth Engine?

我是 Earth Engine 的新手,我很难确定基于栅格和矢量数据输入以及地理兴趣点获取像素级表格数据的最佳方法。

我融合了 table 非洲地理兴趣点 ("interest")、汉森全球森林覆盖观察栅格 ("gfc2014_c"),以及地区和撒哈拉以南非洲国家 ("SSA")。

//Load the Hansen data and create layers
var gfc2014 = ee.Image('UMD/hansen/global_forest_change_2015');

//Load the SSA administrative district shapefile
var SSA = ee.FeatureCollection('users/salem043/Africa_Districts')

//Crop the Hansen data we are interested in to the SSA admin shapefile
var gfc2014_c = gfc2014.clip(SSA);

//Load the data points of interest from the fusion table
var interest = ee.FeatureCollection('ft:1DCL5m_EO8kKMis2BWTdzfg-i9uc4uAZ2xNLQuhf7');

我想为每个兴趣点提取 GFC 数据(所有基础波段)。但我也想要来自 shapefile 的信息 - 我需要变量来识别点所在的几何形状。

我找到的包含有关此任务的一些信息的一页是 here:

所以我尝试了他们的方法,只使用 GFC 数据,如下所示(同样,这主要取自上面的 link)。

var mapfunc = function(feat) {
  // get feature id
  var id = ee.String(feat.id())
  // get feature geometry
  var geom = feat.geometry()
  // make an empty list to store the features
  var newfc = ee.List([])
  // function to iterate over the ImageCollection
  var addProp = function(img, fc) {
    // the initial value is the empty list
    fc = ee.List(fc)
    // get the date as string
    var date = img.date().format()
    // extract the value of 'waterClass'
    var value = img.reduceRegion(ee.Reducer.first(), geom, 30).get('waterClass')
    // If the value is null then store it as 'No data'
    var val = ee.String(ee.Algorithms.If(value, ee.String(value), ee.String('No data')))
    // make the name of the feature (feat_id-date)
    var featname = ee.String("feat_").cat(id).cat(ee.String("-")).cat(date)
    // make the Feature
    var newfeat = ee.Feature(geom, {name:featname,
                                    value:val})
    // add the value to the list
    return fc.add(newfeat)
  }
  var newfeat = ee.FeatureCollection(ee.List(gfc2014.iterate(addProp, newfc)))
  return newfeat
};

var newft = interest.map(mapfunc).flatten();

Export.table.toDrive(newft,
"export_Points",
"export_Points",
"export_Points");

当我 运行 这个时,我得到一个错误 "gfc2014.iterate is not a function"

即使我能让上面的功能正常工作,我也不知道如何从 shapefile 中提取其他信息。最终结果应该有兴趣点 ID(在融合中 table)、兴趣点国家、地区和兴趣点的所有 Hansen 数据值。

非常感谢任何线索或建议!非常感谢您的宝贵时间!

我有一种方法可以做到这一点。由于我无法访问您的图层,我冒昧地创建了几个我自己的点和多边形。

首先,您需要将多边形的属性复制到该多边形内的所有点。我首先在空间上连接多边形(SSA)和点(兴趣)层,这样我就可以拥有多边形中点的属性。我可以通过创建一个查看 .geo

的 Join 对象来做到这一点
// Define a spatial filter as geometries that intersect.
var spatialFilter = ee.Filter.intersects({
  leftField: '.geo',
  rightField: '.geo'
});

// Join the points and polygons and apply spatial filter to keep only
// intersecting ones
var joinAll = ee.Join.saveAll('matched').apply(points, poly, spatialFilter);

由于连接只是将符合条件的多边形添加为点的新 属性,我这样做是为了提取信息。

var featuresWithProp = joinAll.map(function(feature){
  var joinedFeat =  ee.List(feature.get('matched'));
  var polygon = ee.Feature(ee.FeatureCollection(joinedFeat).first());
  return ee.Feature(feature.copyProperties(polygon, properties)).select(properties);
});

最后我使用这些点对 gfc 层进行采样

var sampledPoints = gfc2014.sampleRegions({
  collection:featuresWithProp,
  properties:properties,
  scale:30,
  geometries:true
})

你可以看到一个工作示例here