ee.DateRange.intersection

  • The DateRange.intersection() method returns a new DateRange object representing the overlapping period of the current DateRange and another specified DateRange.

  • This method takes one argument, other, which is the DateRange to intersect with.

  • Examples are provided in both JavaScript and Python demonstrating how to find the intersection of two ee.DateRange objects.

Returns a DateRange that contains all points in the intersection of this DateRange and another.

UsageReturns
DateRange.intersection(other)DateRange
ArgumentTypeDetails
this: dateRangeDateRange
otherDateRange

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-01', '2018-08-24');

// Determine the intersection of two ee.DateRange objects.
print('Intersection of dateRange1 and dateRange2',
      dateRange1.intersection(dateRange2));

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-01', '2018-08-24')

# Determine the intersection of two ee.DateRange objects.
display(
    'Intersection of date_range_1 and date_range_2:',
    date_range_1.intersection(date_range_2)
)