공지사항:
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 Earth Engine 액세스를 유지하기 위해
비상업용 자격 요건을 인증해야 합니다.
ee.ImageCollection.count
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
일치하는 모든 밴드의 스택에서 각 픽셀에 유효한 마스크가 있는 이미지 수를 계산하여 이미지 컬렉션을 줄입니다. 밴드는 이름으로 일치합니다.
사용 | 반환 값 |
---|
ImageCollection.count() | 이미지 |
인수 | 유형 | 세부정보 |
---|
다음과 같은 경우: collection | ImageCollection | 줄일 이미지 컬렉션입니다. |
예
코드 편집기 (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 설정
Python API 및 geemap
를 사용한 대화형 개발에 관한 자세한 내용은
Python 환경 페이지를 참고하세요.
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
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003e\u003ccode\u003eImageCollection.count()\u003c/code\u003e reduces an image collection by calculating the number of images with valid data at each pixel location.\u003c/p\u003e\n"],["\u003cp\u003eBands with the same name are matched across images within the collection for the calculation.\u003c/p\u003e\n"],["\u003cp\u003ePixels with no valid observations are masked out in the resulting image.\u003c/p\u003e\n"],["\u003cp\u003eThe output is a single image where pixel values represent the count of valid observations.\u003c/p\u003e\n"]]],["The `ImageCollection.count()` method reduces an image collection into a single image by counting the number of images with a valid mask at each pixel, across all matching bands. Bands are matched by name. It returns an image where each pixel's value represents the frequency of valid observations at that location. An example in the provided code uses this method to count cloud-free observations. The collection can be reduced by a variety of methods.\n"],null,["# ee.ImageCollection.count\n\nReduces an image collection by calculating the number of images with a valid mask at each pixel across the stack of all matching bands. Bands are matched by name.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------|---------|\n| ImageCollection.count`()` | Image |\n\n| Argument | Type | Details |\n|--------------------|-----------------|---------------------------------|\n| this: `collection` | ImageCollection | The image collection to reduce. |\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```"]]