Announcement: All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain Earth Engine access.
ee.DateRange.isEmpty
Stay organized with collections
Save and categorize content based on your preferences.
Returns true if this DateRange contains no dates (i.e. start >= end).
Usage | Returns | DateRange.isEmpty() | Boolean |
Argument | Type | Details | this: dateRange | DateRange | |
Examples
Code Editor (JavaScript)
// A series of ee.DateRange objects.
var dateRange1 = ee.DateRange('2017-06-24', '2017-07-24');
var dateRange2 = ee.DateRange('2017-07-24', '2017-06-24');
var dateRange3 = ee.DateRange('2017-07-24', '2017-07-24');
// Determine if the ee.DateRange is empty.
print('Is dateRange1 empty?', dateRange1.isEmpty());
print('Is dateRange2 empty?', dateRange2.isEmpty());
print('Is dateRange3 empty?', dateRange3.isEmpty());
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
Colab (Python)
# A series of ee.DateRange objects.
date_range_1 = ee.DateRange('2017-06-24', '2017-07-24')
date_range_2 = ee.DateRange('2017-07-24', '2017-06-24')
date_range_3 = ee.DateRange('2017-07-24', '2017-07-24')
# Determine if the ee.DateRange is empty.
display('Is date_range_1 empty?', date_range_1.isEmpty())
display('Is date_range_2 empty?', date_range_2.isEmpty())
display('Is date_range_3 empty?', date_range_3.isEmpty())
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eDateRange.isEmpty()\u003c/code\u003e method returns \u003ccode\u003etrue\u003c/code\u003e if the DateRange object represents an empty time interval (i.e., the start date is equal to or later than the end date).\u003c/p\u003e\n"],["\u003cp\u003eIt can be applied to any \u003ccode\u003eee.DateRange\u003c/code\u003e object to check its validity.\u003c/p\u003e\n"],["\u003cp\u003eIf the start date is earlier than the end date, the DateRange is considered valid and the method returns \u003ccode\u003efalse\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eWhen the start and end dates are the same, the \u003ccode\u003eDateRange.isEmpty()\u003c/code\u003e method will also return \u003ccode\u003etrue\u003c/code\u003e, indicating an empty or instantaneous range.\u003c/p\u003e\n"]]],["The `isEmpty()` method checks if a `DateRange` contains no dates. It returns a boolean value: `true` if the start date is greater than or equal to the end date, `false` otherwise. It operates on a `DateRange` object. Examples demonstrate creating `DateRange` objects and using `isEmpty()` to check their status, outputting the boolean result in both Javascript and python.\n"],null,["# ee.DateRange.isEmpty\n\nReturns true if this DateRange contains no dates (i.e. start \\\u003e= end).\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------|---------|\n| DateRange.isEmpty`()` | Boolean |\n\n| Argument | Type | Details |\n|-------------------|-----------|---------|\n| this: `dateRange` | DateRange | |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A series of ee.DateRange objects.\nvar dateRange1 = ee.DateRange('2017-06-24', '2017-07-24');\nvar dateRange2 = ee.DateRange('2017-07-24', '2017-06-24');\nvar dateRange3 = ee.DateRange('2017-07-24', '2017-07-24');\n\n// Determine if the ee.DateRange is empty.\nprint('Is dateRange1 empty?', dateRange1.isEmpty());\nprint('Is dateRange2 empty?', dateRange2.isEmpty());\nprint('Is dateRange3 empty?', dateRange3.isEmpty());\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 series of ee.DateRange objects.\ndate_range_1 = ee.DateRange('2017-06-24', '2017-07-24')\ndate_range_2 = ee.DateRange('2017-07-24', '2017-06-24')\ndate_range_3 = ee.DateRange('2017-07-24', '2017-07-24')\n\n# Determine if the ee.DateRange is empty.\ndisplay('Is date_range_1 empty?', date_range_1.isEmpty())\ndisplay('Is date_range_2 empty?', date_range_2.isEmpty())\ndisplay('Is date_range_3 empty?', date_range_3.isEmpty())\n```"]]