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())