Duyuru:
15 Nisan 2025'ten önce Earth Engine'i kullanmak için kaydedilen tüm ticari olmayan projelerin Earth Engine erişimini sürdürmek için
ticari olmayan uygunluğu doğrulaması gerekir.
ee.ImageCollection.mosaic
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Maskeyi kullanarak bir koleksiyondaki tüm resimleri birleştirir.
Kullanım | İadeler |
---|
ImageCollection.mosaic() | Resim |
Bağımsız Değişken | Tür | Ayrıntılar |
---|
bu: collection | ImageCollection | Mozaik yapılacak koleksiyon. |
Örnekler
Kod Düzenleyici (JavaScript)
// Sentinel-2 image collection for July 2021 intersecting a point of interest.
// Reflectance, cloud probability, and scene classification bands are selected.
var col = ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate('2021-07-01', '2021-08-01')
.filterBounds(ee.Geometry.Point(-122.373, 37.448))
.select('B.*|MSK_CLDPRB|SCL');
// Visualization parameters for reflectance RGB.
var visRefl = {
bands: ['B11', 'B8', 'B3'],
min: 0,
max: 4000
};
Map.setCenter(-122.373, 37.448, 9);
Map.addLayer(col, visRefl, 'Collection reference', false);
// Reduce the collection to a single image using a variety of methods.
var mean = col.mean();
Map.addLayer(mean, visRefl, 'Mean (B11, B8, B3)');
var median = col.median();
Map.addLayer(median, visRefl, 'Median (B11, B8, B3)');
var min = col.min();
Map.addLayer(min, visRefl, 'Min (B11, B8, B3)');
var max = col.max();
Map.addLayer(max, visRefl, 'Max (B11, B8, B3)');
var sum = col.sum();
Map.addLayer(sum,
{bands: ['MSK_CLDPRB'], min: 0, max: 500}, 'Sum (MSK_CLDPRB)');
var product = col.product();
Map.addLayer(product,
{bands: ['MSK_CLDPRB'], min: 0, max: 1e10}, 'Product (MSK_CLDPRB)');
// ee.ImageCollection.mode returns the most common value. If multiple mode
// values occur, the minimum mode value is returned.
var mode = col.mode();
Map.addLayer(mode, {bands: ['SCL'], min: 1, max: 11}, 'Mode (pixel class)');
// ee.ImageCollection.count returns the frequency of valid observations. Here,
// image pixels are masked based on cloud probability to add valid observation
// variability to the collection. Note that pixels with no valid observations
// are masked out of the returned image.
var notCloudCol = col.map(function(img) {
return img.updateMask(img.select('MSK_CLDPRB').lte(10));
});
var count = notCloudCol.count();
Map.addLayer(count, {min: 1, max: 5}, 'Count (not cloud observations)');
// ee.ImageCollection.mosaic composites images according to their position in
// the collection (priority is last to first) and pixel mask status, where
// invalid (mask value 0) pixels are filled by preceding valid (mask value >0)
// pixels.
var mosaic = notCloudCol.mosaic();
Map.addLayer(mosaic, visRefl, 'Mosaic (B11, B8, B3)');
Python kurulumu
Python API'si ve etkileşimli geliştirme için geemap
kullanımı hakkında bilgi edinmek üzere
Python Ortamı sayfasına bakın.
import ee
import geemap.core as geemap
Colab (Python)
# Sentinel-2 image collection for July 2021 intersecting a point of interest.
# Reflectance, cloud probability, and scene classification bands are selected.
col = (
ee.ImageCollection('COPERNICUS/S2_SR')
.filterDate('2021-07-01', '2021-08-01')
.filterBounds(ee.Geometry.Point(-122.373, 37.448))
.select('B.*|MSK_CLDPRB|SCL')
)
# Visualization parameters for reflectance RGB.
vis_refl = {'bands': ['B11', 'B8', 'B3'], 'min': 0, 'max': 4000}
m = geemap.Map()
m.set_center(-122.373, 37.448, 9)
m.add_layer(col, vis_refl, 'Collection reference', False)
# Reduce the collection to a single image using a variety of methods.
mean = col.mean()
m.add_layer(mean, vis_refl, 'Mean (B11, B8, B3)')
median = col.median()
m.add_layer(median, vis_refl, 'Median (B11, B8, B3)')
min = col.min()
m.add_layer(min, vis_refl, 'Min (B11, B8, B3)')
max = col.max()
m.add_layer(max, vis_refl, 'Max (B11, B8, B3)')
sum = col.sum()
m.add_layer(
sum, {'bands': ['MSK_CLDPRB'], 'min': 0, 'max': 500}, 'Sum (MSK_CLDPRB)'
)
product = col.product()
m.add_layer(
product,
{'bands': ['MSK_CLDPRB'], 'min': 0, 'max': 1e10},
'Product (MSK_CLDPRB)',
)
# ee.ImageCollection.mode returns the most common value. If multiple mode
# values occur, the minimum mode value is returned.
mode = col.mode()
m.add_layer(
mode, {'bands': ['SCL'], 'min': 1, 'max': 11}, 'Mode (pixel class)'
)
# ee.ImageCollection.count returns the frequency of valid observations. Here,
# image pixels are masked based on cloud probability to add valid observation
# variability to the collection. Note that pixels with no valid observations
# are masked out of the returned image.
not_cloud_col = col.map(
lambda img: img.updateMask(img.select('MSK_CLDPRB').lte(10))
)
count = not_cloud_col.count()
m.add_layer(count, {'min': 1, 'max': 5}, 'Count (not cloud observations)')
# ee.ImageCollection.mosaic composites images according to their position in
# the collection (priority is last to first) and pixel mask status, where
# invalid (mask value 0) pixels are filled by preceding valid (mask value >0)
# pixels.
mosaic = not_cloud_col.mosaic()
m.add_layer(mosaic, vis_refl, 'Mosaic (B11, B8, B3)')
m
Aksi belirtilmediği sürece bu sayfanın içeriği Creative Commons Atıf 4.0 Lisansı altında ve kod örnekleri Apache 2.0 Lisansı altında lisanslanmıştır. Ayrıntılı bilgi için Google Developers Site Politikaları'na göz atın. Java, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-26 UTC.
[null,null,["Son güncelleme tarihi: 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eImageCollection.mosaic()\u003c/code\u003e composites all images within a collection based on their order and mask status.\u003c/p\u003e\n"],["\u003cp\u003eThe function prioritizes images later in the collection and uses valid pixels to fill in invalid ones from earlier images.\u003c/p\u003e\n"],["\u003cp\u003eInvalid pixels have a mask value of 0, while valid pixels have a mask value greater than 0.\u003c/p\u003e\n"],["\u003cp\u003eThis method is useful for creating cloud-free composites or filling in gaps in image coverage.\u003c/p\u003e\n"]]],["The `mosaic()` function composites images within an `ImageCollection` into a single `Image`. It prioritizes the order of images from last to first in the collection. The pixel mask status also plays a role, invalid pixels (mask value 0) are filled by valid pixels (mask value \u003e 0) from preceding images. This function can be used in both JavaScript and Python. Several other reduction functions are exemplified.\n"],null,["# ee.ImageCollection.mosaic\n\nComposites all the images in a collection, using the mask.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------|---------|\n| ImageCollection.mosaic`()` | Image |\n\n| Argument | Type | Details |\n|--------------------|-----------------|---------------------------|\n| this: `collection` | ImageCollection | The collection to mosaic. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Sentinel-2 image collection for July 2021 intersecting a point of interest.\n// Reflectance, cloud probability, and scene classification bands are selected.\nvar col = ee.ImageCollection('COPERNICUS/S2_SR')\n .filterDate('2021-07-01', '2021-08-01')\n .filterBounds(ee.Geometry.Point(-122.373, 37.448))\n .select('B.*|MSK_CLDPRB|SCL');\n\n// Visualization parameters for reflectance RGB.\nvar visRefl = {\n bands: ['B11', 'B8', 'B3'],\n min: 0,\n max: 4000\n};\nMap.setCenter(-122.373, 37.448, 9);\nMap.addLayer(col, visRefl, 'Collection reference', false);\n\n// Reduce the collection to a single image using a variety of methods.\nvar mean = col.mean();\nMap.addLayer(mean, visRefl, 'Mean (B11, B8, B3)');\n\nvar median = col.median();\nMap.addLayer(median, visRefl, 'Median (B11, B8, B3)');\n\nvar min = col.min();\nMap.addLayer(min, visRefl, 'Min (B11, B8, B3)');\n\nvar max = col.max();\nMap.addLayer(max, visRefl, 'Max (B11, B8, B3)');\n\nvar sum = col.sum();\nMap.addLayer(sum,\n {bands: ['MSK_CLDPRB'], min: 0, max: 500}, 'Sum (MSK_CLDPRB)');\n\nvar product = col.product();\nMap.addLayer(product,\n {bands: ['MSK_CLDPRB'], min: 0, max: 1e10}, 'Product (MSK_CLDPRB)');\n\n// ee.ImageCollection.mode returns the most common value. If multiple mode\n// values occur, the minimum mode value is returned.\nvar mode = col.mode();\nMap.addLayer(mode, {bands: ['SCL'], min: 1, max: 11}, 'Mode (pixel class)');\n\n// ee.ImageCollection.count returns the frequency of valid observations. Here,\n// image pixels are masked based on cloud probability to add valid observation\n// variability to the collection. Note that pixels with no valid observations\n// are masked out of the returned image.\nvar notCloudCol = col.map(function(img) {\n return img.updateMask(img.select('MSK_CLDPRB').lte(10));\n});\nvar count = notCloudCol.count();\nMap.addLayer(count, {min: 1, max: 5}, 'Count (not cloud observations)');\n\n// ee.ImageCollection.mosaic composites images according to their position in\n// the collection (priority is last to first) and pixel mask status, where\n// invalid (mask value 0) pixels are filled by preceding valid (mask value \u003e0)\n// pixels.\nvar mosaic = notCloudCol.mosaic();\nMap.addLayer(mosaic, visRefl, 'Mosaic (B11, B8, B3)');\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# Sentinel-2 image collection for July 2021 intersecting a point of interest.\n# Reflectance, cloud probability, and scene classification bands are selected.\ncol = (\n ee.ImageCollection('COPERNICUS/S2_SR')\n .filterDate('2021-07-01', '2021-08-01')\n .filterBounds(ee.Geometry.Point(-122.373, 37.448))\n .select('B.*|MSK_CLDPRB|SCL')\n)\n\n# Visualization parameters for reflectance RGB.\nvis_refl = {'bands': ['B11', 'B8', 'B3'], 'min': 0, 'max': 4000}\nm = geemap.Map()\nm.set_center(-122.373, 37.448, 9)\nm.add_layer(col, vis_refl, 'Collection reference', False)\n\n# Reduce the collection to a single image using a variety of methods.\nmean = col.mean()\nm.add_layer(mean, vis_refl, 'Mean (B11, B8, B3)')\n\nmedian = col.median()\nm.add_layer(median, vis_refl, 'Median (B11, B8, B3)')\n\nmin = col.min()\nm.add_layer(min, vis_refl, 'Min (B11, B8, B3)')\n\nmax = col.max()\nm.add_layer(max, vis_refl, 'Max (B11, B8, B3)')\n\nsum = col.sum()\nm.add_layer(\n sum, {'bands': ['MSK_CLDPRB'], 'min': 0, 'max': 500}, 'Sum (MSK_CLDPRB)'\n)\n\nproduct = col.product()\nm.add_layer(\n product,\n {'bands': ['MSK_CLDPRB'], 'min': 0, 'max': 1e10},\n 'Product (MSK_CLDPRB)',\n)\n\n# ee.ImageCollection.mode returns the most common value. If multiple mode\n# values occur, the minimum mode value is returned.\nmode = col.mode()\nm.add_layer(\n mode, {'bands': ['SCL'], 'min': 1, 'max': 11}, 'Mode (pixel class)'\n)\n\n# ee.ImageCollection.count returns the frequency of valid observations. Here,\n# image pixels are masked based on cloud probability to add valid observation\n# variability to the collection. Note that pixels with no valid observations\n# are masked out of the returned image.\nnot_cloud_col = col.map(\n lambda img: img.updateMask(img.select('MSK_CLDPRB').lte(10))\n)\ncount = not_cloud_col.count()\nm.add_layer(count, {'min': 1, 'max': 5}, 'Count (not cloud observations)')\n\n# ee.ImageCollection.mosaic composites images according to their position in\n# the collection (priority is last to first) and pixel mask status, where\n# invalid (mask value 0) pixels are filled by preceding valid (mask value \u003e0)\n# pixels.\nmosaic = not_cloud_col.mosaic()\nm.add_layer(mosaic, vis_refl, 'Mosaic (B11, B8, B3)')\nm\n```"]]