ee.Image.add
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Thêm giá trị đầu tiên vào giá trị thứ hai cho mỗi cặp dải tần số trùng khớp trong image1 và image2. Nếu image1 hoặc image2 chỉ có 1 dải tần, thì dải tần đó sẽ được dùng cho tất cả các dải tần trong hình ảnh còn lại. Nếu các hình ảnh có cùng số lượng dải tần nhưng không có cùng tên, thì chúng sẽ được sử dụng theo cặp theo thứ tự tự nhiên. Các dải đầu ra được đặt tên theo dải đầu vào dài hơn trong hai dải đầu vào, hoặc nếu chúng có độ dài bằng nhau, thì theo thứ tự của image1. Loại pixel đầu ra là hợp của các loại đầu vào.
Cách sử dụng | Giá trị trả về |
---|
Image.add(image2) | Hình ảnh |
Đối số | Loại | Thông tin chi tiết |
---|
this: image1 | Hình ảnh | Hình ảnh mà từ đó các dải toán hạng bên trái được lấy. |
image2 | Hình ảnh | Hình ảnh mà từ đó các dải toán hạng bên phải được lấy. |
Ví dụ
Trình soạn thảo mã (JavaScript)
// A Sentinel-2 surface reflectance image.
var img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');
// Subset two image bands and display them on the map.
var swir1 = img.select('B11');
var swir2 = img.select('B12');
Map.setCenter(-122.276, 37.456, 12);
Map.addLayer(swir1, {min: 0, max: 3000}, 'swir1');
Map.addLayer(swir2, {min: 0, max: 3000}, 'swir2');
// The following examples demonstrate ee.Image arithmetic methods using two
// single-band ee.Image inputs.
var addition = swir1.add(swir2);
Map.addLayer(addition, {min: 100, max: 6000}, 'addition');
var subtraction = swir1.subtract(swir2);
Map.addLayer(subtraction, {min: 0, max: 1500}, 'subtraction');
var multiplication = swir1.multiply(swir2);
Map.addLayer(multiplication, {min: 1.9e5, max: 9.4e6}, 'multiplication');
var division = swir1.divide(swir2);
Map.addLayer(division, {min: 0, max: 3}, 'division');
var remainder = swir1.mod(swir2);
Map.addLayer(remainder, {min: 0, max: 1500}, 'remainder');
// If a number input is provided as the second argument, it will automatically
// be promoted to an ee.Image object, a convenient shorthand for constants.
var exponent = swir1.pow(3);
Map.addLayer(exponent, {min: 0, max: 2e10}, 'exponent');
Thiết lập Python
Hãy xem trang
Môi trường Python để biết thông tin về API Python và cách sử dụng geemap
cho quá trình phát triển tương tác.
import ee
import geemap.core as geemap
Colab (Python)
# A Sentinel-2 surface reflectance image.
img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')
# Subset two image bands and display them on the map.
swir_1 = img.select('B11')
swir_2 = img.select('B12')
m = geemap.Map()
m.set_center(-122.276, 37.456, 12)
m.add_layer(swir_1, {'min': 0, 'max': 3000}, 'swir_1')
m.add_layer(swir_2, {'min': 0, 'max': 3000}, 'swir_2')
# The following examples demonstrate ee.Image arithmetic methods using two
# single-band ee.Image inputs.
addition = swir_1.add(swir_2)
m.add_layer(addition, {'min': 100, 'max': 6000}, 'addition')
subtraction = swir_1.subtract(swir_2)
m.add_layer(subtraction, {'min': 0, 'max': 1500}, 'subtraction')
multiplication = swir_1.multiply(swir_2)
m.add_layer(multiplication, {'min': 1.9e5, 'max': 9.4e6}, 'multiplication')
division = swir_1.divide(swir_2)
m.add_layer(division, {'min': 0, 'max': 3}, 'division')
remainder = swir_1.mod(swir_2)
m.add_layer(remainder, {'min': 0, 'max': 1500}, 'remainder')
# If a number input is provided as the second argument, it will automatically
# be promoted to an ee.Image object, a convenient shorthand for constants.
exponent = swir_1.pow(3)
m.add_layer(exponent, {'min': 0, 'max': 2e10}, 'exponent')
m
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eImage.add()\u003c/code\u003e performs pixel-wise addition between two images, adding the values of corresponding bands.\u003c/p\u003e\n"],["\u003cp\u003eIf the input images have different numbers of bands, the single-band image is applied to all bands of the multi-band image.\u003c/p\u003e\n"],["\u003cp\u003eOutput band names and data types are determined based on the input images, prioritizing the longer or first image.\u003c/p\u003e\n"],["\u003cp\u003eNumerical inputs are automatically converted to images, allowing for operations with constants.\u003c/p\u003e\n"],["\u003cp\u003eThis function is commonly used for arithmetic calculations on raster data, such as combining spectral bands or applying offsets.\u003c/p\u003e\n"]]],["The `add()` method combines two images by adding corresponding band values. If one image has a single band, it's applied to all bands of the other. When both images have multiple bands with different names, bands are added pairwise. Output band names are taken from the longer input image, or the first if they are equal in length, with output pixel type being the union of the two inputs.\n"],null,["# ee.Image.add\n\nAdds the first value to the second for each matched pair of bands in image1 and image2. If either image1 or image2 has only 1 band, then it is used against all the bands in the other image. If the images have the same number of bands, but not the same names, they're used pairwise in the natural order. The output bands are named for the longer of the two inputs, or if they're equal in length, in image1's order. The type of the output pixels is the union of the input types.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------|---------|\n| Image.add`(image2)` | Image |\n\n| Argument | Type | Details |\n|----------------|-------|---------------------------------------------------------|\n| this: `image1` | Image | The image from which the left operand bands are taken. |\n| `image2` | Image | The image from which the right operand bands are taken. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A Sentinel-2 surface reflectance image.\nvar img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');\n\n// Subset two image bands and display them on the map.\nvar swir1 = img.select('B11');\nvar swir2 = img.select('B12');\nMap.setCenter(-122.276, 37.456, 12);\nMap.addLayer(swir1, {min: 0, max: 3000}, 'swir1');\nMap.addLayer(swir2, {min: 0, max: 3000}, 'swir2');\n\n// The following examples demonstrate ee.Image arithmetic methods using two\n// single-band ee.Image inputs.\nvar addition = swir1.add(swir2);\nMap.addLayer(addition, {min: 100, max: 6000}, 'addition');\n\nvar subtraction = swir1.subtract(swir2);\nMap.addLayer(subtraction, {min: 0, max: 1500}, 'subtraction');\n\nvar multiplication = swir1.multiply(swir2);\nMap.addLayer(multiplication, {min: 1.9e5, max: 9.4e6}, 'multiplication');\n\nvar division = swir1.divide(swir2);\nMap.addLayer(division, {min: 0, max: 3}, 'division');\n\nvar remainder = swir1.mod(swir2);\nMap.addLayer(remainder, {min: 0, max: 1500}, 'remainder');\n\n// If a number input is provided as the second argument, it will automatically\n// be promoted to an ee.Image object, a convenient shorthand for constants.\nvar exponent = swir1.pow(3);\nMap.addLayer(exponent, {min: 0, max: 2e10}, 'exponent');\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 Sentinel-2 surface reflectance image.\nimg = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')\n\n# Subset two image bands and display them on the map.\nswir_1 = img.select('B11')\nswir_2 = img.select('B12')\nm = geemap.Map()\nm.set_center(-122.276, 37.456, 12)\nm.add_layer(swir_1, {'min': 0, 'max': 3000}, 'swir_1')\nm.add_layer(swir_2, {'min': 0, 'max': 3000}, 'swir_2')\n\n# The following examples demonstrate ee.Image arithmetic methods using two\n# single-band ee.Image inputs.\naddition = swir_1.add(swir_2)\nm.add_layer(addition, {'min': 100, 'max': 6000}, 'addition')\n\nsubtraction = swir_1.subtract(swir_2)\nm.add_layer(subtraction, {'min': 0, 'max': 1500}, 'subtraction')\n\nmultiplication = swir_1.multiply(swir_2)\nm.add_layer(multiplication, {'min': 1.9e5, 'max': 9.4e6}, 'multiplication')\n\ndivision = swir_1.divide(swir_2)\nm.add_layer(division, {'min': 0, 'max': 3}, 'division')\n\nremainder = swir_1.mod(swir_2)\nm.add_layer(remainder, {'min': 0, 'max': 1500}, 'remainder')\n\n# If a number input is provided as the second argument, it will automatically\n# be promoted to an ee.Image object, a convenient shorthand for constants.\nexponent = swir_1.pow(3)\nm.add_layer(exponent, {'min': 0, 'max': 2e10}, 'exponent')\nm\n```"]]