ee.ImageCollection.filterDate

Lối tắt để lọc một bộ sưu tập theo phạm vi ngày. Ngày bắt đầu và ngày kết thúc có thể là Ngày, số (được hiểu là số mili giây kể từ 00:00:00 ngày 1 tháng 1 năm 1970 theo giờ UTC) hoặc chuỗi (chẳng hạn như "1996-01-01T08:00"). Dựa trên "system:time_start".

Điều này tương đương với this.filter(ee.Filter.date(...)); hãy xem loại ee.Filter để biết các lựa chọn lọc theo ngày khác.

Trả về tập hợp đã lọc.

Cách sử dụngGiá trị trả về
ImageCollection.filterDate(start, end)Bộ sưu tập
Đối sốLoạiThông tin chi tiết
this: collectionBộ sưu tậpPhiên bản Bộ sưu tập.
startNgày|Số|ChuỗiNgày bắt đầu (bao gồm cả ngày này).
endDate|Number|String, không bắt buộcNgày kết thúc (không bao gồm). Không bắt buộc. Nếu không được chỉ định, một phạm vi 1 mili giây bắt đầu từ "start" sẽ được tạo.

Ví dụ

Trình soạn thảo mã (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));

Thiết lập Python

Hãy xem trang Môi trường Python để biết thông tin về API Python và cách sử dụng geemap cho quá trình phát triển tương tác.

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())