Объявление : Все некоммерческие проекты, зарегистрированные для использования Earth Engine до
15 апреля 2025 года, должны
подтвердить некоммерческое право на сохранение доступа к Earth Engine.
ee.Filter.calendarRange
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Возвращает фильтр, который проходит проверку, если временная метка объекта попадает в заданный диапазон поля календаря.
month
,
day_of_year
,
day_of_month
и
day_of_week
начинаются с 1. Предполагается, что время указано в формате UTC. Предполагается, что неделя начинается с понедельника, как с первого дня. Если
end
<
start
, то проверяется, что
value
>=
start
ИЛИ
value
<=
end
, чтобы обеспечить перенос.
Использование | Возврат | ee.Filter.calendarRange(start, end , field ) | Фильтр |
Аргумент | Тип | Подробности | start | Целое число | Начало желаемого поля календаря, включительно. |
end | Целое число, по умолчанию: null | Конец нужного поля календаря включительно. По умолчанию имеет то же значение, что и начало. |
field | Строка, по умолчанию: "day_of_year" | Поле календаря для фильтрации. Возможные варианты: `год`, `месяц`, `час`, `минута`, `день_года`, `день_месяца` и `день_недели`. |
Примеры
Редактор кода (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
Информацию об API Python и использовании 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()
)
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-07-24 UTC.
[null,null,["Последнее обновление: 2025-07-24 UTC."],[[["\u003cp\u003eFilters objects based on whether their timestamp falls within a specified calendar date range (e.g., month, day of year).\u003c/p\u003e\n"],["\u003cp\u003eAllows filtering by various calendar fields like year, month, hour, minute, day of year, day of month, and day of week, with "day_of_year" as the default.\u003c/p\u003e\n"],["\u003cp\u003eAccepts start and end values for the range, with the end defaulting to the start value if not specified.\u003c/p\u003e\n"],["\u003cp\u003eSupports wrapping, meaning if \u003ccode\u003eend\u003c/code\u003e is less than \u003ccode\u003estart\u003c/code\u003e, it filters for values greater than or equal to \u003ccode\u003estart\u003c/code\u003e OR less than or equal to \u003ccode\u003eend\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAssumes times are in UTC and weeks begin on Monday.\u003c/p\u003e\n"]]],[],null,["# ee.Filter.calendarRange\n\nReturns a filter that passes if the object's timestamp falls within the given range of a calendar field. The `month`, `day_of_year`, `day_of_month`, and `day_of_week` are 1-based. Times are assumed to be in UTC. Weeks are assumed to begin on Monday as day 1. If `end` \\\u003c `start` then this tests for `value` \\\u003e= `start` OR `value` \\\u003c= `end`, to allow for wrapping.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-------------------------------------------------------|---------|\n| `ee.Filter.calendarRange(start, `*end* `, `*field*`)` | Filter |\n\n| Argument | Type | Details |\n|----------|--------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `start` | Integer | The start of the desired calendar field, inclusive. |\n| `end` | Integer, default: null | The end of the desired calendar field, inclusive. Defaults to the same value as start. |\n| `field` | String, default: \"day_of_year\" | The calendar field to filter over. Options are: \\`year\\`, \\`month\\`, \\`hour\\`, \\`minute\\`, \\`day_of_year\\`, \\`day_of_month\\`, and \\`day_of_week\\`. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A Sentinel-2 surface reflectance image collection intersecting the peak of\n// Mount Shasta, California, USA.\nvar ic = ee.ImageCollection('COPERNICUS/S2_SR')\n .filterBounds(ee.Geometry.Point(-122.196, 41.411));\n\nprint('Images for a month range (June-August)',\n ic.filter(ee.Filter.calendarRange(6, 8, 'month')));\n\nprint('A start value greater than end value is valid (Dec-Feb)',\n ic.filter(ee.Filter.calendarRange(12, 2, 'month')));\n\n// This example uses the 'year' field value. Note that ee.Filter.date is the\n// preferred method when filtering by whole years, as it is much faster.\nprint('Images for a year range (2020-2021)',\n ic.filter(ee.Filter.calendarRange(2020, 2021, 'year')));\n\n// This example uses the 'day_of_year' field value. Note that\n// ee.Filter.dayOfYear is the preferred method for filtering by DOY.\n// The ee.Date.getRelative function is used to identify DOY from an ee.Date\n// object for a representative year. Be mindful of leap years when filtering\n// by DOY.\nvar startDoy = ee.Date('2000-06-01').getRelative('day', 'year');\nvar endDoy = ee.Date('2000-06-15').getRelative('day', 'year');\nprint('start DOY =', startDoy,\n 'end DOY =', endDoy,\n 'Images for a day-of-year range',\n ic.filter(ee.Filter.calendarRange(startDoy, endDoy, 'day_of_year')));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# A Sentinel-2 surface reflectance image collection intersecting the peak of\n# Mount Shasta, California, USA.\nic = ee.ImageCollection('COPERNICUS/S2_SR').filterBounds(\n ee.Geometry.Point(-122.196, 41.411))\n\nprint('Images for a month range (June-August):',\n ic.filter(ee.Filter.calendarRange(6, 8, 'month')).getInfo())\n\nprint('A start value greater than end value is valid (Dec-Feb):',\n ic.filter(ee.Filter.calendarRange(12, 2, 'month')).size().getInfo())\n\n# This example uses the 'year' field value. Note that ee.Filter.date is the\n# preferred method when filtering by whole years, as it is much faster.\nprint('Images for a year range (2020-2021):',\n ic.filter(ee.Filter.calendarRange(2020, 2021, 'year')).size().getInfo())\n\n# This example uses the 'day_of_year' field value. Note that\n# ee.Filter.dayOfYear is the preferred method for filtering by DOY.\n# The ee.Date.getRelative function is used to identify DOY from an ee.Date\n# object for a representative year. Be mindful of leap years when filtering\n# by DOY.\nstart_doy = ee.Date('2000-06-01').getRelative('day', 'year')\nend_doy = ee.Date('2000-06-15').getRelative('day', 'year')\nprint('start DOY =', start_doy.getInfo(), 'end DOY =', end_doy.getInfo())\nprint(\n 'Images for a day-of-year range:',\n ic.filter(ee.Filter.calendarRange(start_doy, end_doy, 'day_of_year'))\n .getInfo()\n)\n```"]]