إشعار: يجب
إثبات أهلية جميع المشاريع غير التجارية المسجّلة لاستخدام Earth Engine قبل
15 أبريل 2025 من أجل الحفاظ على إمكانية الوصول إلى Earth Engine.
ee.FeatureCollection.distance
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تُنتج هذه الدالة صورة DOUBLE حيث تكون قيمة كل بكسل هي المسافة بالأمتار من مركز البكسل إلى أقرب نقطة أو خط أو حدود مضلّعية في المجموعة. يُرجى العِلم أنّه يتم أيضًا قياس المسافة داخل المضلّعات. سيتم إخفاء وحدات البكسل التي لا تقع ضمن نطاق "searchRadius" مترًا من شكل هندسي.
يتم احتساب المسافات على كرة، لذا هناك خطأ صغير يتناسب مع الفرق في خطوط العرض بين كل بكسل وأقرب شكل هندسي.
الاستخدام | المرتجعات |
---|
FeatureCollection.distance(searchRadius, maxError) | صورة |
الوسيطة | النوع | التفاصيل |
---|
هذا: features | FeatureCollection | مجموعة العناصر التي سيتم الحصول منها على العناصر المستخدَمة لاحتساب مسافات البكسل |
searchRadius | عدد صحيح، القيمة التلقائية: 100000 | الحد الأقصى للمسافة بالأمتار من كل بكسل للبحث عن الحواف سيتم إخفاء وحدات البكسل ما لم تكن هناك حواف ضمن هذه المسافة. |
maxError | Float، القيمة التلقائية: 100 | الحدّ الأقصى لخطأ إعادة العرض بالكيلومترات، ويتم استخدامه فقط إذا كانت الخطوط المتعددة المدخلة تتطلّب إعادة عرض. في حال توفير القيمة 0، ستفشل هذه العملية إذا كانت هناك حاجة إلى العرض. |
أمثلة
محرّر الرموز البرمجية (JavaScript)
// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
.filter('country_lg == "Belgium"');
// Generate an image of distance to nearest power plant.
var distance = fc.distance({searchRadius: 50000, maxError: 50});
// Display the image and FeatureCollection on the map.
Map.setCenter(4.56, 50.78, 7);
Map.addLayer(distance, {max: 50000}, 'Distance to power plants');
Map.addLayer(fc, {color: 'red'}, 'Power plants');
إعداد Python
راجِع صفحة
بيئة Python للحصول على معلومات حول واجهة برمجة التطبيقات Python واستخدام
geemap
للتطوير التفاعلي.
import ee
import geemap.core as geemap
Colab (Python)
# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
'country_lg == "Belgium"'
)
# Generate an image of distance to nearest power plant.
distance = fc.distance(searchRadius=50000, maxError=50)
# Display the image and FeatureCollection on the map.
m = geemap.Map()
m.set_center(4.56, 50.78, 7)
m.add_layer(distance, {'max': 50000}, 'Distance to power plants')
m.add_layer(fc, {'color': 'red'}, 'Power plants')
m
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eComputes the distance (in meters) from each pixel to the nearest point, line, or polygon within a given FeatureCollection.\u003c/p\u003e\n"],["\u003cp\u003eGenerates a double-precision image where pixel values represent the distance to the nearest feature.\u003c/p\u003e\n"],["\u003cp\u003eOffers adjustable search radius and maximum error parameters for controlling computation.\u003c/p\u003e\n"],["\u003cp\u003ePixels beyond the search radius or exceeding the error threshold are masked out.\u003c/p\u003e\n"],["\u003cp\u003eCalculations consider the Earth's curvature for accurate distance measurements.\u003c/p\u003e\n"]]],[],null,["# ee.FeatureCollection.distance\n\nProduces a DOUBLE image where each pixel is the distance in meters from the pixel center to the nearest Point, LineString, or polygonal boundary in the collection. Note distance is also measured within interiors of polygons. Pixels that are not within 'searchRadius' meters of a geometry will be masked out.\n\n\u003cbr /\u003e\n\nDistances are computed on a sphere, so there is a small error proportional to the latitude difference between each pixel and the nearest geometry.\n\n| Usage | Returns |\n|---------------------------------------------------------------|---------|\n| FeatureCollection.distance`(`*searchRadius* `, `*maxError*`)` | Image |\n\n| Argument | Type | Details |\n|------------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `features` | FeatureCollection | Feature collection from which to get features used to compute pixel distances. |\n| `searchRadius` | Float, default: 100000 | Maximum distance in meters from each pixel to look for edges. Pixels will be masked unless there are edges within this distance. |\n| `maxError` | Float, default: 100 | Maximum reprojection error in meters, only used if the input polylines require reprojection. If '0' is provided, then this operation will fail if projection is required. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// FeatureCollection of power plants in Belgium.\nvar fc = ee.FeatureCollection('WRI/GPPD/power_plants')\n .filter('country_lg == \"Belgium\"');\n\n// Generate an image of distance to nearest power plant.\nvar distance = fc.distance({searchRadius: 50000, maxError: 50});\n\n// Display the image and FeatureCollection on the map.\nMap.setCenter(4.56, 50.78, 7);\nMap.addLayer(distance, {max: 50000}, 'Distance to power plants');\nMap.addLayer(fc, {color: 'red'}, 'Power plants');\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\n# FeatureCollection of power plants in Belgium.\nfc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(\n 'country_lg == \"Belgium\"'\n)\n\n# Generate an image of distance to nearest power plant.\ndistance = fc.distance(searchRadius=50000, maxError=50)\n\n# Display the image and FeatureCollection on the map.\nm = geemap.Map()\nm.set_center(4.56, 50.78, 7)\nm.add_layer(distance, {'max': 50000}, 'Distance to power plants')\nm.add_layer(fc, {'color': 'red'}, 'Power plants')\nm\n```"]]