ee.Image.normalizedDifference
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
คำนวณความแตกต่างที่ผ่านการปรับให้เป็นมาตรฐานระหว่าง 2 แถบ หากไม่ได้ระบุแถบที่จะใช้ ระบบจะใช้ 2 แถบแรก ความแตกต่างที่ปรับให้เป็นมาตรฐานจะคำนวณเป็น (first − second) / (first + second) โปรดทราบว่าชื่อแถบรูปภาพที่ส่งคืนคือ "nd" ระบบจะไม่เก็บพร็อพเพอร์ตี้รูปภาพอินพุตไว้ในรูปภาพเอาต์พุต และค่าพิกเซลที่เป็นลบในแถบอินพุตจะทำให้ระบบมาสก์พิกเซลเอาต์พุต หากไม่ต้องการมาสก์ค่าอินพุตที่เป็นลบ ให้ใช้
ee.Image.expression()
เพื่อคำนวณความแตกต่างที่ทำให้เป็นมาตรฐาน
การใช้งาน | การคืนสินค้า |
---|
Image.normalizedDifference(bandNames) | รูปภาพ |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
ดังนี้ input | รูปภาพ | รูปภาพที่อินพุตเข้ามา |
bandNames | รายการ (ค่าเริ่มต้น: null) | รายการชื่อที่ระบุย่านความถี่ที่จะใช้ หากไม่ได้ระบุ ระบบจะใช้แถบความถี่แรกและแถบความถี่ที่สอง |
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (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 API และการใช้ geemap
เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
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
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\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```"]]