公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.Image.divide
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
将第一个值除以第二个值,如果 image1 和 image2 中每个匹配的波段都除以 0,则返回 0。如果 image1 或 image2 只有一个波段,则会将其与另一张图片中的所有波段进行比较。如果图片具有相同数量的波段,但名称不同,则会按自然顺序成对使用。输出波段的命名方式为:如果两个输入的长度不同,则以较长的输入命名;如果长度相同,则以 image1 的顺序命名。输出像素的类型是输入类型的并集。
用法 | 返回 |
---|
Image.divide(image2) | 图片 |
参数 | 类型 | 详细信息 |
---|
此:image1 | 图片 | 从中获取左操作数波段的映像。 |
image2 | 图片 | 从中获取右操作数波段的映像。 |
示例
代码编辑器 (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');
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
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
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eimage1.divide(image2)\u003c/code\u003e performs element-wise division between matching bands of two images, returning 0 for divisions by 0.\u003c/p\u003e\n"],["\u003cp\u003eIf the input images have different numbers of bands, single-band images are applied to all bands of the other image, and if they have the same number of bands but different names, bands are paired in their natural order.\u003c/p\u003e\n"],["\u003cp\u003eThe output image's band names and type are determined by the longer input image or, if equal in length, by \u003ccode\u003eimage1\u003c/code\u003e's properties.\u003c/p\u003e\n"],["\u003cp\u003eThe output pixel type is derived from the union of the input pixel types, accommodating potential differences in data representation.\u003c/p\u003e\n"]]],[],null,["# ee.Image.divide\n\nDivides the first value by the second, returning 0 for division by 0 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.divide`(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```"]]