إشعار: يجب
إثبات أهلية جميع المشاريع غير التجارية المسجّلة لاستخدام Earth Engine قبل
15 أبريل 2025 من أجل الحفاظ على إمكانية الوصول إلى Earth Engine.
ee.Image.normalizedDifference
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تحسب هذه الدالة الفرق المعدَّل بين نطاقَين. في حال عدم تحديد النطاقات المطلوب استخدامها، يتم استخدام أول نطاقَين. يتم احتساب الفرق المعدَّل على النحو التالي: (القيمة الأولى − القيمة الثانية) / (القيمة الأولى + القيمة الثانية). يُرجى العِلم أنّ اسم نطاق الصورة المعروضة هو "nd"، ولا يتم الاحتفاظ بخصائص الصورة المُدخَلة في الصورة الناتجة، كما أنّ قيمة البكسل السالبة في أيّ من النطاقات المُدخَلة ستؤدي إلى إخفاء البكسل الناتج. لتجنُّب إخفاء قيم الإدخال السالبة، استخدِم
ee.Image.expression()
لاحتساب الفرق المعدَّل.
الاستخدام | المرتجعات |
---|
Image.normalizedDifference(bandNames) | صورة |
الوسيطة | النوع | التفاصيل |
---|
هذا: input | صورة | الصورة المدخَلة |
bandNames | قائمة، القيمة التلقائية: فارغة | قائمة بالأسماء التي تحدّد النطاقات المطلوب استخدامها. في حال عدم تحديد ذلك، يتم استخدام النطاقَين الأول والثاني. |
أمثلة
محرّر الرموز البرمجية (JavaScript)
// A Landsat 8 surface reflectance image.
var img = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20210508');
// Calculate normalized difference vegetation index: (NIR - Red) / (NIR + Red).
var nirBand = 'SR_B5';
var redBand = 'SR_B4';
var ndvi = img.normalizedDifference([nirBand, redBand]);
// Display NDVI result on the map.
Map.setCenter(-122.148, 37.377, 11);
Map.addLayer(ndvi, {min: 0, max: 0.5}, 'NDVI');
إعداد Python
راجِع صفحة
بيئة Python للحصول على معلومات حول واجهة برمجة التطبيقات Python واستخدام
geemap
للتطوير التفاعلي.
import ee
import geemap.core as geemap
Colab (Python)
# A Landsat 8 surface reflectance image.
img = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20210508')
# Calculate normalized difference vegetation index: (NIR - Red) / (NIR + Red).
nir_band = 'SR_B5'
red_band = 'SR_B4'
ndvi = img.normalizedDifference([nir_band, red_band])
# Display NDVI result on the map.
m = geemap.Map()
m.set_center(-122.148, 37.377, 11)
m.add_layer(ndvi, {'min': 0, 'max': 0.5}, 'NDVI')
m
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eComputes the normalized difference between two specified or default image bands using the formula (first - second) / (first + second).\u003c/p\u003e\n"],["\u003cp\u003eReturns a single-band image named 'nd' representing the normalized difference.\u003c/p\u003e\n"],["\u003cp\u003eInput image properties are not preserved in the output, and negative input values in either band result in masked output pixels.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eee.Image.expression()\u003c/code\u003e is recommended for handling negative input values and avoiding masking.\u003c/p\u003e\n"]]],[],null,["# ee.Image.normalizedDifference\n\nComputes the normalized difference between two bands. If the bands to use are not specified, uses the first two bands. The normalized difference is computed as (first − second) / (first + second). Note that the returned image band name is 'nd', the input image properties are not retained in the output image, and a negative pixel value in either input band will cause the output pixel to be masked. To avoid masking negative input values, use `ee.Image.expression()` to compute normalized difference.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------------------------|---------|\n| Image.normalizedDifference`(`*bandNames*`)` | Image |\n\n| Argument | Type | Details |\n|---------------|---------------------|-----------------------------------------------------------------------------------------------------|\n| this: `input` | Image | The input image. |\n| `bandNames` | List, default: null | A list of names specifying the bands to use. If not specified, the first and second bands are used. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A Landsat 8 surface reflectance image.\nvar img = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20210508');\n\n// Calculate normalized difference vegetation index: (NIR - Red) / (NIR + Red).\nvar nirBand = 'SR_B5';\nvar redBand = 'SR_B4';\nvar ndvi = img.normalizedDifference([nirBand, redBand]);\n\n// Display NDVI result on the map.\nMap.setCenter(-122.148, 37.377, 11);\nMap.addLayer(ndvi, {min: 0, max: 0.5}, 'NDVI');\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# A Landsat 8 surface reflectance image.\nimg = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20210508')\n\n# Calculate normalized difference vegetation index: (NIR - Red) / (NIR + Red).\nnir_band = 'SR_B5'\nred_band = 'SR_B4'\nndvi = img.normalizedDifference([nir_band, red_band])\n\n# Display NDVI result on the map.\nm = geemap.Map()\nm.set_center(-122.148, 37.377, 11)\nm.add_layer(ndvi, {'min': 0, 'max': 0.5}, 'NDVI')\nm\n```"]]