ee.Geometry

تنشئ هذه الدالة شكلاً هندسيًا.

الاستخدامالمرتجعات
ee.Geometry(geoJson, proj, geodesic, evenOdd)هندسة
الوسيطةالنوعالتفاصيل
geoJsonعنصركائن GeoJSON يصف الشكل الهندسي أو ComputedObject سيتم إعادة تفسيره كشكل هندسي. يتوافق مع مواصفات نظام الإسناد المكاني (CRS) وفقًا لمواصفات GeoJSON، ولكنّه يسمح فقط باستخدام أنظمة إسناد مكاني مسماة (بدلاً من أنظمة إسناد مكاني "مرتبطة"). إذا كان هذا يتضمّن حقل "جيوديسي" ولم يتم تحديد opt_geodesic، سيتم استخدامه كـ opt_geodesic.
projالتوقّعات، اختياريةمواصفات نظام الإسقاط الاختيارية، إما كرمز تعريف لنظام الإحداثيات المرجعية أو كسلسلة WKT. في حال تحديدها، تلغي أي نظام إحداثيات مرجعي تم العثور عليه في المَعلمة geoJson. إذا لم يتم تحديدها ولم يعرّف geoJson نظام الإحداثيات المرجعي (CRS)، يتم ضبط القيمة التلقائية على "EPSG:4326" (س=خط الطول، ص=خط العرض).
geodesicقيمة منطقية، اختياريةلتحديد ما إذا كان يجب تفسير القطع المستقيمة على أنّها خطوط جيوديسية كروية. إذا كانت القيمة false، يشير ذلك إلى أنّه يجب تفسير مقاطع الخطوط على أنّها خطوط مستوية في نظام الإحداثيات المرجعي المحدّد. في حال عدم توفّره، تكون القيمة التلقائية هي "صحيح" إذا كان نظام الإحداثيات المرجعي جغرافيًا (بما في ذلك EPSG:4326 التلقائي)، أو "خطأ" إذا كان نظام الإحداثيات المرجعي مسقطًا.
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 للحصول على معلومات حول واجهة برمجة التطبيقات Python واستخدام geemap للتطوير التفاعلي.

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