公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
过滤 ImageCollection
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如“开始使用”部分和“ImageCollection 信息”部分所述,Earth Engine 提供了多种便捷的方法来过滤影像集。
具体而言,许多常见用例由 imageCollection.filterDate()
和 imageCollection.filterBounds()
处理。对于通用过滤,请使用 imageCollection.filter()
并将 ee.Filter
用作参数。以下示例演示了使用便捷方法和 filter()
从 ImageCollection
中识别和移除云量较高的图片。
Code Editor (JavaScript)
// Load Landsat 8 data, filter by date, month, and bounds.
var collection = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
.filterDate('2015-01-01', '2018-01-01') // Three years of data
.filter(ee.Filter.calendarRange(11, 2, 'month')) // Only Nov-Feb observations
.filterBounds(ee.Geometry.Point(25.8544, -18.08874)); // Intersecting ROI
// Also filter the collection by the CLOUD_COVER property.
var filtered = collection.filter(ee.Filter.eq('CLOUD_COVER', 0));
// Create two composites to check the effect of filtering by CLOUD_COVER.
var badComposite = collection.mean();
var goodComposite = filtered.mean();
// Display the composites.
Map.setCenter(25.8544, -18.08874, 13);
Map.addLayer(badComposite,
{bands: ['B3', 'B2', 'B1'], min: 0.05, max: 0.35, gamma: 1.1},
'Bad composite');
Map.addLayer(goodComposite,
{bands: ['B3', 'B2', 'B1'], min: 0.05, max: 0.35, gamma: 1.1},
'Good composite');
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
# Load Landsat 8 data, filter by date, month, and bounds.
collection = (
ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
# Three years of data
.filterDate('2015-01-01', '2018-01-01')
# Only Nov-Feb observations
.filter(ee.Filter.calendarRange(11, 2, 'month'))
# Intersecting ROI
.filterBounds(ee.Geometry.Point(25.8544, -18.08874))
)
# Also filter the collection by the CLOUD_COVER property.
filtered = collection.filter(ee.Filter.eq('CLOUD_COVER', 0))
# Create two composites to check the effect of filtering by CLOUD_COVER.
bad_composite = collection.mean()
good_composite = filtered.mean()
# Display the composites.
m = geemap.Map()
m.set_center(25.8544, -18.08874, 13)
m.add_layer(
bad_composite,
{'bands': ['B3', 'B2', 'B1'], 'min': 0.05, 'max': 0.35, 'gamma': 1.1},
'Bad composite',
)
m.add_layer(
good_composite,
{'bands': ['B3', 'B2', 'B1'], 'min': 0.05, 'max': 0.35, 'gamma': 1.1},
'Good composite',
)
m
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eEarth Engine provides multiple methods for filtering image collections, including convenience functions like \u003ccode\u003efilterDate()\u003c/code\u003e and \u003ccode\u003efilterBounds()\u003c/code\u003e as well as the more general \u003ccode\u003efilter()\u003c/code\u003e method for custom filtering needs.\u003c/p\u003e\n"],["\u003cp\u003eThis example demonstrates how to filter a Landsat 8 image collection by date, month, geographic bounds, and cloud cover using these methods.\u003c/p\u003e\n"],["\u003cp\u003eFiltering by cloud cover significantly improves the quality of composites derived from image collections, as shown by comparing a composite generated from unfiltered data with one generated from data filtered for zero cloud cover.\u003c/p\u003e\n"],["\u003cp\u003eThe code example is provided in both JavaScript and Python, enabling users to apply these filtering techniques in their preferred programming environment within the Earth Engine platform.\u003c/p\u003e\n"]]],["The content demonstrates filtering image collections in Earth Engine. It uses `filterDate()`, `filterBounds()`, and `filter()` to refine a Landsat 8 dataset. The data is filtered by date (2015-2018), month (November-February), and a specific location. Further filtering removes images with high cloud cover using `CLOUD_COVER`. Two composites, one filtered for low cloud cover and one unfiltered, are then created and displayed to illustrate the effect of filtering.\n"],null,["# Filtering an ImageCollection\n\nAs illustrated in the [Get Started section](/earth-engine/guides/getstarted)\nand the [ImageCollection Information section](/earth-engine/guides/ic_info), Earth\nEngine provides a variety of convenience methods for filtering image collections.\nSpecifically, many common use cases are handled by `imageCollection.filterDate()`,\nand `imageCollection.filterBounds()`. For general purpose filtering, use\n`imageCollection.filter()` with an `ee.Filter` as an argument. The\nfollowing example demonstrates both convenience methods and `filter()`\nto identify and remove images with high cloud cover from an `ImageCollection`.\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load Landsat 8 data, filter by date, month, and bounds.\nvar collection = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterDate('2015-01-01', '2018-01-01') // Three years of data\n .filter(ee.Filter.calendarRange(11, 2, 'month')) // Only Nov-Feb observations\n .filterBounds(ee.Geometry.Point(25.8544, -18.08874)); // Intersecting ROI\n\n// Also filter the collection by the CLOUD_COVER property.\nvar filtered = collection.filter(ee.Filter.eq('CLOUD_COVER', 0));\n\n// Create two composites to check the effect of filtering by CLOUD_COVER.\nvar badComposite = collection.mean();\nvar goodComposite = filtered.mean();\n\n// Display the composites.\nMap.setCenter(25.8544, -18.08874, 13);\nMap.addLayer(badComposite,\n {bands: ['B3', 'B2', 'B1'], min: 0.05, max: 0.35, gamma: 1.1},\n 'Bad composite');\nMap.addLayer(goodComposite,\n {bands: ['B3', 'B2', 'B1'], min: 0.05, max: 0.35, gamma: 1.1},\n 'Good composite');\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# Load Landsat 8 data, filter by date, month, and bounds.\ncollection = (\n ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n # Three years of data\n .filterDate('2015-01-01', '2018-01-01')\n # Only Nov-Feb observations\n .filter(ee.Filter.calendarRange(11, 2, 'month'))\n # Intersecting ROI\n .filterBounds(ee.Geometry.Point(25.8544, -18.08874))\n)\n\n# Also filter the collection by the CLOUD_COVER property.\nfiltered = collection.filter(ee.Filter.eq('CLOUD_COVER', 0))\n\n# Create two composites to check the effect of filtering by CLOUD_COVER.\nbad_composite = collection.mean()\ngood_composite = filtered.mean()\n\n# Display the composites.\nm = geemap.Map()\nm.set_center(25.8544, -18.08874, 13)\nm.add_layer(\n bad_composite,\n {'bands': ['B3', 'B2', 'B1'], 'min': 0.05, 'max': 0.35, 'gamma': 1.1},\n 'Bad composite',\n)\nm.add_layer(\n good_composite,\n {'bands': ['B3', 'B2', 'B1'], 'min': 0.05, 'max': 0.35, 'gamma': 1.1},\n 'Good composite',\n)\nm\n```"]]