ee.Filter.calendarRange

แสดงผลตัวกรองที่ผ่านหากการประทับเวลาของออบเจ็กต์อยู่ในช่วงที่กำหนดของฟิลด์ปฏิทิน month, day_of_year, day_of_month และ day_of_week มีฐานเป็น 1 ระบบจะถือว่าเวลาเป็นเวลา UTC ระบบจะถือว่าสัปดาห์เริ่มต้นในวันจันทร์เป็นวันที่ 1 หาก end < start แสดงว่าการทดสอบนี้มีไว้สำหรับ value >= start หรือ value <= end เพื่อให้ข้อความตัดคำได้

การใช้งานการคืนสินค้า
ee.Filter.calendarRange(start, end, field)ตัวกรอง
อาร์กิวเมนต์ประเภทรายละเอียด
startจำนวนเต็มจุดเริ่มต้นของฟิลด์ปฏิทินที่ต้องการ โดยรวมวันที่เริ่มต้นด้วย
endจำนวนเต็ม ค่าเริ่มต้น: nullจุดสิ้นสุดของช่องปฏิทินที่ต้องการ โดยนับรวมวันที่ดังกล่าวด้วย ค่าเริ่มต้นจะเท่ากับค่าเริ่มต้น
fieldString, ค่าเริ่มต้น: "day_of_year"ฟิลด์ปฏิทินที่จะกรอง ตัวเลือก ได้แก่ `year`, `month`, `hour`, `minute`, `day_of_year`, `day_of_month` และ `day_of_week`

ตัวอย่าง

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

// A Sentinel-2 surface reflectance image collection intersecting the peak of
// Mount Shasta, California, USA.
var ic = ee.ImageCollection('COPERNICUS/S2_SR')
             .filterBounds(ee.Geometry.Point(-122.196, 41.411));

print('Images for a month range (June-August)',
      ic.filter(ee.Filter.calendarRange(6, 8, 'month')));

print('A start value greater than end value is valid (Dec-Feb)',
      ic.filter(ee.Filter.calendarRange(12, 2, 'month')));

// This example uses the 'year' field value. Note that ee.Filter.date is the
// preferred method when filtering by whole years, as it is much faster.
print('Images for a year range (2020-2021)',
      ic.filter(ee.Filter.calendarRange(2020, 2021, 'year')));

// This example uses the 'day_of_year' field value. Note that
// ee.Filter.dayOfYear is the preferred method for filtering by DOY.
// The ee.Date.getRelative function is used to identify DOY from an ee.Date
// object for a representative year. Be mindful of leap years when filtering
// by DOY.
var startDoy = ee.Date('2000-06-01').getRelative('day', 'year');
var endDoy = ee.Date('2000-06-15').getRelative('day', 'year');
print('start DOY =', startDoy,
      'end DOY =', endDoy,
      'Images for a day-of-year range',
      ic.filter(ee.Filter.calendarRange(startDoy, endDoy, 'day_of_year')));

การตั้งค่า Python

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

import ee
import geemap.core as geemap

Colab (Python)

# A Sentinel-2 surface reflectance image collection intersecting the peak of
# Mount Shasta, California, USA.
ic = ee.ImageCollection('COPERNICUS/S2_SR').filterBounds(
    ee.Geometry.Point(-122.196, 41.411))

print('Images for a month range (June-August):',
      ic.filter(ee.Filter.calendarRange(6, 8, 'month')).getInfo())

print('A start value greater than end value is valid (Dec-Feb):',
      ic.filter(ee.Filter.calendarRange(12, 2, 'month')).size().getInfo())

# This example uses the 'year' field value. Note that ee.Filter.date is the
# preferred method when filtering by whole years, as it is much faster.
print('Images for a year range (2020-2021):',
      ic.filter(ee.Filter.calendarRange(2020, 2021, 'year')).size().getInfo())

# This example uses the 'day_of_year' field value. Note that
# ee.Filter.dayOfYear is the preferred method for filtering by DOY.
# The ee.Date.getRelative function is used to identify DOY from an ee.Date
# object for a representative year. Be mindful of leap years when filtering
# by DOY.
start_doy = ee.Date('2000-06-01').getRelative('day', 'year')
end_doy = ee.Date('2000-06-15').getRelative('day', 'year')
print('start DOY =', start_doy.getInfo(), 'end DOY =', end_doy.getInfo())
print(
    'Images for a day-of-year range:',
    ic.filter(ee.Filter.calendarRange(start_doy, end_doy, 'day_of_year'))
    .getInfo()
)