ee.ImageCollection.filterDate

按日期范围过滤集合的快捷方式。开始时间和结束时间可以是日期、数字(解释为自 1970-01-01T00:00:00Z 以来的毫秒数)或字符串(例如“1996-01-01T08:00”)。基于“system:time_start”。

这相当于 this.filter(ee.Filter.date(...));如需了解其他日期过滤选项,请参阅 ee.Filter 类型。

返回过滤后的集合。

用法返回
ImageCollection.filterDate(start, end)集合
参数类型详细信息
此:collection集合Collection 实例。
start日期|数字|字符串开始日期(含)。
endDate|Number|String,可选结束日期(不含)。可选。如果未指定,则会创建一个从“start”开始的 1 毫秒范围。

示例

代码编辑器 (JavaScript)

// A Landsat 8 TOA image collection intersecting a specific point.
var col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
  .filterBounds(ee.Geometry.Point(-90.70, 34.71));

// Filter the collection by date using date strings.
print('2020 images', col.filterDate('2020', '2021'));
print('July images, 2020', col.filterDate('2020-07', '2020-08'));
print('Early July images, 2020', col.filterDate('2020-07-01', '2020-07-10'));
print('Include time (13 hours, July 7, 2020)',
      col.filterDate('2020-07-05T06:34:46', '2020-07-05T19:34:46'));

// Use milliseconds since Unix epoch.
print('Milliseconds inputs', col.filterDate(1593967014062, 1595349419611));

// Use ee.Date objects.
print('ee.Date inputs', col.filterDate(ee.Date('2020'), ee.Date('2021')));

// Use an ee.DateRange object.
var dateRange = ee.DateRange('2020-07-01', '2020-07-10');
print('ee.DateRange input', col.filterDate(dateRange));

Python 设置

如需了解 Python API 和如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。

import ee
import geemap.core as geemap

Colab (Python)

# A Landsat 8 TOA image collection intersecting a specific point.
col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA').filterBounds(
    ee.Geometry.Point(-90.70, 34.71))

# Filter the collection by date using date strings.
print('2020 images:', col.filterDate('2020', '2021').getInfo())
print('July images, 2020:', col.filterDate('2020-07', '2020-08').getInfo())
print('Early July images, 2020:',
      col.filterDate('2020-07-01', '2020-07-10').getInfo())
print('Include time (13 hours, July 7, 2020):',
      col.filterDate('2020-07-05T06:34:46', '2020-07-05T19:34:46').getInfo())

# Use milliseconds since Unix epoch.
print('Milliseconds inputs:',
      col.filterDate(1593967014062, 1595349419611).getInfo())

# Use ee.Date objects.
print('ee.Date inputs',
      col.filterDate(ee.Date('2020'), ee.Date('2021')).getInfo())

# Use an ee.DateRange object.
date_range = ee.DateRange('2020-07-01', '2020-07-10')
print('ee.DateRange input', col.filterDate(date_range).getInfo())