إشعار: يجب
إثبات أهلية جميع المشاريع غير التجارية المسجّلة لاستخدام Earth Engine قبل
15 أبريل 2025 من أجل الحفاظ على إمكانية الوصول إلى Earth Engine.
ee.Image.constant
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تنشئ هذه العقدة صورة تحتوي على قيمة ثابتة في كل مكان.
الاستخدام | المرتجعات |
---|
ee.Image.constant(value) | صورة |
الوسيطة | النوع | التفاصيل |
---|
value | عنصر | قيمة وحدات البكسل في الصورة الثابتة يجب أن يكون رقمًا أو مصفوفة أو قائمة أرقام أو مصفوفات. |
أمثلة
محرّر الرموز البرمجية (JavaScript)
// Create a constant image, where every pixel has bands of the same value.
var image1 = ee.Image.constant(1);
Map.addLayer(image1, null, '1');
// Image (1 band)
// type: Image
// bands: List (1 element)
// 0: "constant", int ∈ [1, 1], EPSG:4326
print(image1);
var image2 = ee.Image(2);
Map.addLayer(image2, null, '2');
// Image (1 band)
// type: Image
// bands: List (1 element)
// 0: "constant", int ∈ [2, 2], EPSG:4326
print(image2);
var π = ee.Image(Math.PI);
Map.addLayer(π, null, 'π');
// Image (1 band)
// type: Image
// bands: List (1 element)
// 0: "constant", double ∈ [3.141592653589793, 3.141592653589793], EPSG:4326
// id: constant
// crs: EPSG:4326
// crs_transform: [1,0,0,0,1,0]
// data_type: double ∈ [3.141592653589793, 3.141592653589793]
print(π);
// Create a multi-band image from a list of constant double integers.
var doubleIntImage = ee.Image.constant([-1.2, 4]);
Map.addLayer(doubleIntImage, null, 'double int');
// Image (2 bands)
// type: Image
// bands: List (2 elements)
// 0: "constant_0", double ∈ [-1.2, -1.2], EPSG:4326
// 1: "constant_1", int ∈ [4, 4], EPSG:4326
print(doubleIntImage);
// Create a multi-band image from a list of constants, using hexadecimal
// notation.
var multiband = ee.Image([0xff, 0x88, 0x00]);
Map.addLayer(multiband, {min: 0, max: 0xff}, 'orange');
// Image (3 bands)
// type: Image
// bands: List (3 elements)
// 0: "constant", int ∈ [255, 255], EPSG:4326
// 1: "constant_1", int ∈ [136, 136], EPSG:4326
// 2: "constant_2", int ∈ [0, 0], EPSG:4326
print(multiband);
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eGenerates an image where every pixel has the same specified value, creating a constant image.\u003c/p\u003e\n"],["\u003cp\u003eAccepts a number, an array, or a list of numbers/arrays as input to define the constant value for the image pixels.\u003c/p\u003e\n"],["\u003cp\u003eCan create single-band or multi-band images with constant values in each band.\u003c/p\u003e\n"],["\u003cp\u003eUses \u003ccode\u003eee.Image.constant(value)\u003c/code\u003e for construction, where 'value' represents the desired constant.\u003c/p\u003e\n"],["\u003cp\u003eCan be visualized using \u003ccode\u003eMap.addLayer()\u003c/code\u003e by providing the image and optional visualization parameters.\u003c/p\u003e\n"]]],[],null,["# ee.Image.constant\n\nGenerates an image containing a constant value everywhere.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------|---------|\n| `ee.Image.constant(value)` | Image |\n\n| Argument | Type | Details |\n|----------|--------|-------------------------------------------------------------------------------------------------------------|\n| `value` | Object | The value of the pixels in the constant image. Must be a number or an Array or a list of numbers or Arrays. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Create a constant image, where every pixel has bands of the same value.\nvar image1 = ee.Image.constant(1);\nMap.addLayer(image1, null, '1');\n// Image (1 band)\n// type: Image\n// bands: List (1 element)\n// 0: \"constant\", int ∈ [1, 1], EPSG:4326\nprint(image1);\n\nvar image2 = ee.Image(2);\nMap.addLayer(image2, null, '2');\n// Image (1 band)\n// type: Image\n// bands: List (1 element)\n// 0: \"constant\", int ∈ [2, 2], EPSG:4326\nprint(image2);\n\nvar π = ee.Image(Math.PI);\nMap.addLayer(π, null, 'π');\n// Image (1 band)\n// type: Image\n// bands: List (1 element)\n// 0: \"constant\", double ∈ [3.141592653589793, 3.141592653589793], EPSG:4326\n// id: constant\n// crs: EPSG:4326\n// crs_transform: [1,0,0,0,1,0]\n// data_type: double ∈ [3.141592653589793, 3.141592653589793]\nprint(π);\n\n// Create a multi-band image from a list of constant double integers.\nvar doubleIntImage = ee.Image.constant([-1.2, 4]);\nMap.addLayer(doubleIntImage, null, 'double int');\n// Image (2 bands)\n// type: Image\n// bands: List (2 elements)\n// 0: \"constant_0\", double ∈ [-1.2, -1.2], EPSG:4326\n// 1: \"constant_1\", int ∈ [4, 4], EPSG:4326\nprint(doubleIntImage);\n\n// Create a multi-band image from a list of constants, using hexadecimal\n// notation.\nvar multiband = ee.Image([0xff, 0x88, 0x00]);\nMap.addLayer(multiband, {min: 0, max: 0xff}, 'orange');\n// Image (3 bands)\n// type: Image\n// bands: List (3 elements)\n// 0: \"constant\", int ∈ [255, 255], EPSG:4326\n// 1: \"constant_1\", int ∈ [136, 136], EPSG:4326\n// 2: \"constant_2\", int ∈ [0, 0], EPSG:4326\nprint(multiband);\n```"]]