Earth Engine 推出了
非商业配额层级,以保护共享计算资源并确保为所有人提供可靠的性能。非商业项目默认使用 Community
层级,但您可以随时更改项目的层级。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
ee.Geometry.coveringGrid
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
返回涵盖此几何图形的一系列要素,其中每个要素都是给定投影所定义的网格中的一个矩形。
| 用法 | 返回 |
|---|
Geometry.coveringGrid(proj, scale) | FeatureCollection |
| 参数 | 类型 | 详细信息 |
|---|
this:geometry | Geometry | 结果是与此区域相交的网格单元格。 |
proj | Projection | 用于构建网格的投影。系统会为与“geometry”相交的每个网格单元格生成一个要素,其中单元格角位于投影中的整数值位置。如果投影以米为单位进行缩放,则点将位于真实比例点处该大小的网格上。 |
scale | 浮点数,默认值:null | 替换投影的比例(如果提供)。如果投影尚未缩放,则可能需要此参数。 |
示例
代码编辑器 (JavaScript)
// Define the coordinate reference system (CRS) to be used for grid alignment.
// WGS 84 / UTM zone 36S.
var epsg = 'EPSG:32736';
// Create a point geometry to serve as the center for the analysis.
var point = ee.Geometry.Point(31.6, -8.54);
Map.addLayer(point, {color: 'orange'}, 'Center');
Map.centerObject(point, 8);
// Create a circular buffer of 100,000 meters (100 km) around the point to
// define the study area.
var areaOfInterest = point.buffer(100000);
Map.addLayer(areaOfInterest, {color: 'purple'}, 'Area of interest');
// Calculate a scale value to determine the size of the grid cells.
// Use a power of 2 for best GeoTIFF tiling, e.g., assuming that we'll use the
// grid cell to define image export regions, 2**14 -> 16384.
var scale = Math.pow(2, 14);
// Generate a FeatureCollection of grid cells that covers the buffered area
// using the specified projection and scale.
var grid = areaOfInterest.coveringGrid({proj: epsg, scale: scale});
Map.addLayer(grid, {color: 'blue'}, 'Covering Grid', true, 0.5);
// Define the specific index string of the grid cell to be extracted.
var cellOfInterest = '18,551';
// Filter the grid collection to find the feature matching the index and
// retrieve it as an ee.Feature.
var feature =
ee.Feature(grid.toList(10000)
.filter(ee.Filter.eq('system:index', cellOfInterest))
.get(0));
Map.addLayer(feature, {color: 'red'}, 'grid cell', true, 0.5);
// One common use of coveringGrid is to tile operations such as exports.
// This often involves iterating through grid cells on the client-side to
// submit tasks for each cell. Here we print each cell ID using evaluate().
print('Grid cell IDs:');
grid.aggregate_array('system:index').evaluate(function(cellIds) {
cellIds.forEach(function(cellId) {
print(cellId);
});
});
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2026-05-23。
[null,null,["最后更新时间 (UTC):2026-05-23。"],[],["The `coveringGrid` function generates a `FeatureCollection` of rectangular grid cells that intersect a given `Geometry`. It uses a specified `Projection` to define the grid, with each cell represented as a feature. The grid's scale is determined by the projection, or overridden by an optional `scale` argument. The function returns cells where their corners are located at integer-valued positions within the specified `Projection`.\n"]]