我已将 *FeatureCollection * 导入到 Google Earth Engine(覆盖欧洲的六边形网格)中。我想获取位于陆地上方的网格单元的子集,并排除仅覆盖水域的网格单元。
目前,我正在使用 Terra Land Water Mask ('MODIS/006/MOD44W') 数据集来区分陆地和水,但无法将其转换为可用于过滤 FeatureCollection 的几何图形。如果可以让事情变得更容易,我愿意使用另一个数据集来区分陆地和水。
因此,出现以下问题:
下面,我发布了我的初步代码,包括我迄今为止尝试过的代码。该代码也可以在以下位置检索: [https://code.earthengine.google.com/6d7bbd3c25a8f8c41f53a17aba3b04e7]
非常感谢任何帮助:)
// LOAD HEXAGONAL GRID
var grid = ee.FeatureCollection("users/livfritsche/reki_grid_epsg4326");
Map.addLayer(grid, {}, 'grid', false)
print('grid', grid)
// LOAD LAND-WATER MASK
var wm = ee.ImageCollection('MODIS/006/MOD44W')
.filter(ee.Filter.date('2015-01-01', '2015-05-01'));
var waterMask = wm.first().select('water_mask');
// compute and plot land mask
var landMask = waterMask.eq(0);
Map.addLayer(landMask, {}, 'Land Mask', false)
// FILTER HEXAGONAL GRID CELLS ACCORDING TO LANDCOVER
// try and fail: convert land mask to polygon, then apply polygon to filter grid
// land mask to polygon
var landMaskGeom = landMask.reduceToVectors({
scale: 10000,
geometry: grid,
geometryType: 'polygon'
});
print('land mask geometry', landMaskGeom)
Map.addLayer(landMaskGeom, {}, 'land mask geometry')
var grid_land = grid.filterBounds(landMaskGeom)
print('grid_land', grid_land)
Map.addLayer(grid_land, {}, 'grid_land')
// output: grid_land still contains all the features from the original FeatureCollection, there was no filtering applied?
// Is 'filterBounds' the right function to use? What shall I use instead?
发现问题了!我会将问题留在网上,以防对其他人有帮助。
缺少 FeatureCollection landMaskGeom 的过滤。仅应使用带有 property 标签 == 1 的 Features。
var landMaskGeomFilt = landMaskGeom.filter(ee.Filter.eq('label', 1))