ee.Geometry
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สร้างเรขาคณิต
การใช้งาน | การคืนสินค้า |
---|
ee.Geometry(geoJson, proj, geodesic, evenOdd) | เรขาคณิต |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
geoJson | วัตถุ | ออบเจ็กต์ GeoJSON ที่อธิบายเรขาคณิตหรือ ComputedObject ที่จะตีความใหม่เป็นเรขาคณิต รองรับข้อกำหนด CRS ตามข้อกำหนด GeoJSON แต่จะอนุญาตเฉพาะ CRS ที่มีชื่อ
(ไม่ใช่ CRS ที่ "ลิงก์") หากมีฟิลด์ "geodesic" และไม่ได้ระบุ opt_geodesic ระบบจะใช้ฟิลด์ดังกล่าวเป็น opt_geodesic |
proj | การคาดการณ์ (ไม่บังคับ) | การระบุการฉายภาพที่ไม่บังคับ ไม่ว่าจะเป็นรหัส CRS หรือสตริง WKT หากระบุไว้ จะลบล้าง CRS ที่พบในพารามิเตอร์ geoJson หากไม่ได้ระบุไว้และ geoJson ไม่ได้ประกาศ CRS ระบบจะใช้ "EPSG:4326" เป็นค่าเริ่มต้น (x=ลองจิจูด, y=ละติจูด) |
geodesic | บูลีน ไม่บังคับ | ควรถือว่าส่วนของเส้นเป็นเส้นโค้งทรงกลมหรือไม่ หากเป็นเท็จ แสดงว่าควรตีความส่วนของเส้นเป็นเส้นระนาบใน CRS ที่ระบุ หากไม่มี ระบบจะตั้งค่าเป็น "จริง" โดยค่าเริ่มต้นหาก CRS เป็นแบบภูมิศาสตร์ (รวมถึง EPSG:4326 เริ่มต้น) หรือตั้งค่าเป็น "เท็จ" หาก CRS เป็นแบบฉาย |
evenOdd | บูลีน ไม่บังคับ | หากเป็นจริง ระบบจะกำหนดขอบเขตด้านในของรูปหลายเหลี่ยมตามกฎคู่/คี่ ซึ่งจุดจะอยู่ด้านในหากตัดขอบเป็นจำนวนคี่เพื่อไปยังจุดที่อนันต์ มิฉะนั้น รูปหลายเหลี่ยมจะใช้กฎด้านในซ้าย ซึ่งภายในจะอยู่ทางด้านซ้ายของขอบเปลือกเมื่อเดินตามจุดยอดตามลำดับที่กำหนด หากไม่ได้ระบุ ระบบจะใช้ค่าเริ่มต้นเป็น "จริง" |
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (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 Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eCreates a geometry from a GeoJSON object, optionally specifying projection, geodesic handling, and polygon winding rule.\u003c/p\u003e\n"],["\u003cp\u003eAccepts GeoJSON objects or strings (which must be parsed into objects).\u003c/p\u003e\n"],["\u003cp\u003eEnables casting of computed geometry objects (like those in Feature properties) to the \u003ccode\u003eee.Geometry\u003c/code\u003e class for method access.\u003c/p\u003e\n"],["\u003cp\u003eSupports both JavaScript and Python environments within Google Earth Engine.\u003c/p\u003e\n"]]],[],null,["# ee.Geometry\n\n\u003cbr /\u003e\n\nCreates a geometry.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------------------------------------------|----------|\n| `ee.Geometry(geoJson, `*proj* `, `*geodesic* `, `*evenOdd*`)` | Geometry |\n\n| Argument | Type | Details |\n|------------|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `geoJson` | Object | The GeoJSON object describing the geometry or a ComputedObject to be reinterpreted as a Geometry. Supports CRS specifications as per the GeoJSON spec, but only allows named (rather than \"linked\" CRSs). If this includes a 'geodesic' field, and opt_geodesic is not specified, it will be used as opt_geodesic. |\n| `proj` | Projection, optional | An optional projection specification, either as a CRS ID code or as a WKT string. If specified, overrides any CRS found in the geoJson parameter. If unspecified and the geoJson does not declare a CRS, defaults to \"EPSG:4326\" (x=longitude, y=latitude). |\n| `geodesic` | Boolean, optional | Whether line segments should be interpreted as spherical geodesics. If false, indicates that line segments should be interpreted as planar lines in the specified CRS. If absent, defaults to true if the CRS is geographic (including the default EPSG:4326), or to false if the CRS is projected. |\n| `evenOdd` | Boolean, optional | If true, polygon interiors will be determined by the even/odd rule, where a point is inside if it crosses an odd number of edges to reach a point at infinity. Otherwise polygons use the left- inside rule, where interiors are on the left side of the shell's edges when walking the vertices in the given order. If unspecified, defaults to true. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A GeoJSON object for a triangular polygon.\nvar geojsonObject = {\n \"type\": \"Polygon\",\n \"coordinates\": [\n [\n [\n -122.085,\n 37.423\n ],\n [\n -122.092,\n 37.424\n ],\n [\n -122.085,\n 37.418\n ],\n [\n -122.085,\n 37.423\n ]\n ]\n ]\n};\nprint('ee.Geometry accepts a GeoJSON object', ee.Geometry(geojsonObject));\n\n// GeoJSON strings need to be converted to an object.\nvar geojsonString = JSON.stringify(geojsonObject);\nprint('A GeoJSON string needs to be converted to an object',\n ee.Geometry(JSON.parse(geojsonString)));\n\n// Use ee.Geometry to cast computed geometry objects into the ee.Geometry\n// class to access their methods. In the following example an ee.Geometry\n// object is stored as a ee.Feature property. When it is retrieved with the\n// .get() function, a computed geometry object is returned. Cast the computed\n// object as a ee.Geometry to get the geometry's bounds, for instance.\nvar feature = ee.Feature(null, {geom: ee.Geometry(geojsonObject)});\nprint('Cast computed geometry objects to ee.Geometry class',\n ee.Geometry(feature.get('geom')).bounds());\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nimport json\n\n# A GeoJSON object for a triangular polygon.\ngeojson_object = {\n 'type': 'Polygon',\n 'coordinates': [\n [\n [\n -122.085,\n 37.423\n ],\n [\n -122.092,\n 37.424\n ],\n [\n -122.085,\n 37.418\n ],\n [\n -122.085,\n 37.423\n ]\n ]\n ]\n}\nprint(\n 'ee.Geometry accepts a GeoJSON object:',\n ee.Geometry(geojson_object).getInfo()\n)\n\n# GeoJSON strings need to be converted to an object.\ngeojson_string = json.dumps(geojson_object)\nprint('A GeoJSON string needs to be converted to an object:',\n ee.Geometry(json.loads(geojson_string)).getInfo())\n\n# Use ee.Geometry to cast computed geometry objects into the ee.Geometry\n# class to access their methods. In the following example an ee.Geometry\n# object is stored as a ee.Feature property. When it is retrieved with the\n# .get() function, a computed geometry object is returned. Cast the computed\n# object as a ee.Geometry to get the geometry's bounds, for instance.\nfeature = ee.Feature(None, {'geom': ee.Geometry(geojson_object)})\nprint('Cast computed geometry objects to ee.Geometry class:',\n ee.Geometry(feature.get('geom')).bounds().getInfo())\n```"]]