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คอลเล็กชันอินสแตนซ์คอลเล็กชัน
startวันที่|ตัวเลข|สตริงวันที่เริ่มต้น (รวมวันที่เริ่มต้น)
endวันที่|ตัวเลข|สตริง ไม่บังคับวันที่สิ้นสุด (ไม่รวม) ไม่บังคับ หากไม่ได้ระบุ ระบบจะสร้างช่วง 1 มิลลิวินาทีโดยเริ่มที่ "start"

ตัวอย่าง

โปรแกรมแก้ไขโค้ด (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())