ee.FeatureCollection.filterDate

ทางลัดในการกรองคอลเล็กชันตามช่วงวันที่ ค่าเริ่มต้นและค่าสิ้นสุดอาจเป็นวันที่ ตัวเลข (ตีความเป็นมิลลิวินาทีนับตั้งแต่ 1970-01-01T00:00:00Z) หรือสตริง (เช่น "1996-01-01T08:00") อิงตาม "system:time_start"

ซึ่งเทียบเท่ากับ this.filter(ee.Filter.date(...)) ดูตัวเลือกการกรองวันที่อื่นๆ ได้ที่ประเภท ee.Filter

แสดงผลคอลเล็กชันที่กรองแล้ว

การใช้งานการคืนสินค้า
FeatureCollection.filterDate(start, end)คอลเล็กชัน
อาร์กิวเมนต์ประเภทรายละเอียด
ดังนี้ collectionคอลเล็กชันอินสแตนซ์คอลเล็กชัน
startวันที่|ตัวเลข|สตริงวันที่เริ่มต้น (รวมวันที่เริ่มต้น)
endวันที่|ตัวเลข|สตริง ไม่บังคับวันที่สิ้นสุด (ไม่รวม) ไม่บังคับ หากไม่ได้ระบุ ระบบจะสร้างช่วง 1 มิลลิวินาทีโดยเริ่มที่ "start"

ตัวอย่าง

โปรแกรมแก้ไขโค้ด (JavaScript)

// Constructed FeatureCollection representing a field site sampled at
// four different dates; date recorded as "system:time_start" property in units
// of milliseconds since Unix epoch.
var geom = ee.Geometry.Point([-119.56, 37.67]);
var fc = ee.FeatureCollection([
  ee.Feature(geom, {'prop': 10, 'system:time_start': ee.Date('2021-06-10')}),
  ee.Feature(geom, {'prop': 11, 'system:time_start': ee.Date('2021-06-20')}),
  ee.Feature(geom, {'prop': 19, 'system:time_start': ee.Date('2021-07-10')}),
  ee.Feature(geom, {'prop': 10, 'system:time_start': ee.Date('2021-07-20')})
]);

// Filter the observations in July 2021.
print('Field site observations collection in July 2021',
      fc.filterDate('2021-07-01', '2021-08-01'));

// Alternative input formats.
print('ee.DateRange as an input',
      fc.filterDate(ee.DateRange('2021-07-01', '2021-08-01')));

print('Numbers (milliseconds since Unix epoch) as an input',
      fc.filterDate(1625875200000, 1626739200001));

print('ee.Date objects as an input',
      fc.filterDate(ee.Date('2021-07-01'), ee.Date('2021-08-01')));

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า สภาพแวดล้อม Python

import ee
import geemap.core as geemap

Colab (Python)

# Constructed FeatureCollection representing a field site sampled at
# four different dates; date recorded as "system:time_start" property in units
# of milliseconds since Unix epoch.
geom = ee.Geometry.Point([-119.56, 37.67])
fc = ee.FeatureCollection([
    ee.Feature(geom, {'prop': 10, 'system:time_start': ee.Date('2021-06-10')}),
    ee.Feature(geom, {'prop': 11, 'system:time_start': ee.Date('2021-06-20')}),
    ee.Feature(geom, {'prop': 19, 'system:time_start': ee.Date('2021-07-10')}),
    ee.Feature(geom, {'prop': 10, 'system:time_start': ee.Date('2021-07-20')})
])

# Filter the observations in July 2021.
print('Field site observations collection in July 2021:',
      fc.filterDate('2021-07-01', '2021-08-01').getInfo())

# Alternative input formats.
print('ee.DateRange as an input:',
      fc.filterDate(ee.DateRange('2021-07-01', '2021-08-01')).getInfo())

print('Numbers (milliseconds since Unix epoch) as an input:',
      fc.filterDate(1625875200000, 1626739200001).getInfo())

print('ee.Date objects as an input:',
      fc.filterDate(ee.Date('2021-07-01'), ee.Date('2021-08-01')).getInfo())