公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Geometry
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
创建几何图形。
用法 | 返回 |
---|
ee.Geometry(geoJson, proj, geodesic, evenOdd) | 几何图形 |
参数 | 类型 | 详细信息 |
---|
geoJson | 对象 | 描述几何图形的 GeoJSON 对象或要重新解释为几何图形的 ComputedObject。支持 GeoJSON 规范中的 CRS 规范,但仅允许命名 CRS(而非“链接”CRS)。如果此参数包含“测地线”字段,并且未指定 opt_geodesic,则此字段将用作 opt_geodesic。 |
proj | 投影,可选 | 可选的投影规范,可以是 CRS ID 代码,也可以是 WKT 字符串。如果指定,则会替换 geoJson 参数中找到的所有 CRS。如果未指定,且 geoJson 未声明 CRS,则默认为“EPSG:4326”(x=经度,y=纬度)。 |
geodesic | 布尔值,可选 | 是否应将线段解读为球面测地线。如果为 false,表示应将线段解释为指定 CRS 中的平面线。如果未指定,则当 CRS 为地理坐标系(包括默认的 EPSG:4326)时,默认值为 true;当 CRS 为投影坐标系时,默认值为 false。 |
evenOdd | 布尔值,可选 | 如果为 true,则多边形内部将由偶数/奇数规则确定,即如果一个点穿过奇数条边才能到达无穷远的点,则该点位于多边形内部。否则,多边形将使用左侧内部规则,即当按给定顺序遍历顶点时,内部位于外壳边缘的左侧。如果未指定,则默认为 true。 |
示例
代码编辑器 (JavaScript)
// A GeoJSON object for a triangular polygon.
var geojsonObject = {
"type": "Polygon",
"coordinates": [
[
[
-122.085,
37.423
],
[
-122.092,
37.424
],
[
-122.085,
37.418
],
[
-122.085,
37.423
]
]
]
};
print('ee.Geometry accepts a GeoJSON object', ee.Geometry(geojsonObject));
// GeoJSON strings need to be converted to an object.
var geojsonString = JSON.stringify(geojsonObject);
print('A GeoJSON string needs to be converted to an object',
ee.Geometry(JSON.parse(geojsonString)));
// Use ee.Geometry to cast computed geometry objects into the ee.Geometry
// class to access their methods. In the following example an ee.Geometry
// object is stored as a ee.Feature property. When it is retrieved with the
// .get() function, a computed geometry object is returned. Cast the computed
// object as a ee.Geometry to get the geometry's bounds, for instance.
var feature = ee.Feature(null, {geom: ee.Geometry(geojsonObject)});
print('Cast computed geometry objects to ee.Geometry class',
ee.Geometry(feature.get('geom')).bounds());
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
import json
# A GeoJSON object for a triangular polygon.
geojson_object = {
'type': 'Polygon',
'coordinates': [
[
[
-122.085,
37.423
],
[
-122.092,
37.424
],
[
-122.085,
37.418
],
[
-122.085,
37.423
]
]
]
}
print(
'ee.Geometry accepts a GeoJSON object:',
ee.Geometry(geojson_object).getInfo()
)
# GeoJSON strings need to be converted to an object.
geojson_string = json.dumps(geojson_object)
print('A GeoJSON string needs to be converted to an object:',
ee.Geometry(json.loads(geojson_string)).getInfo())
# Use ee.Geometry to cast computed geometry objects into the ee.Geometry
# class to access their methods. In the following example an ee.Geometry
# object is stored as a ee.Feature property. When it is retrieved with the
# .get() function, a computed geometry object is returned. Cast the computed
# object as a ee.Geometry to get the geometry's bounds, for instance.
feature = ee.Feature(None, {'geom': ee.Geometry(geojson_object)})
print('Cast computed geometry objects to ee.Geometry class:',
ee.Geometry(feature.get('geom')).bounds().getInfo())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[],[],null,[]]