簡體   English   中英

按相似的采集日期過濾兩個 Google Earth Engine 圖像 collections - 彼此相差一天以內

[英]Filter two Google Earth Engine image collections by similar acquisition dates - within one day of each other

這個問題是基於以前的帖子: https://gis.stackexchange.com/questions/386827/filter-two-image-collections-by-the-same-aqusition-date-in-google-earth-engine

我想擴展問題以嘗試過濾 collections 以Google Earth Engine(python api ).

我在 geemap 中編寫了以下代碼(基於之前的帖子)以獲得重合的圖像日期,給定兩個圖像 collections:

col1 = ee.ImageCollection('LANDSAT/LE07/C02/T1_L2') \
    .filter(ee.Filter.calendarRange(1998, 2013,'year')) \
    .filterBounds(pts)

col2 = ee.ImageCollection('LANDSAT/LT05/C02/T1_L2') \
    .filter(ee.Filter.calendarRange(1998, 2012,'year')) \
    .filterBounds(pts)

def datefunc(image):
    date = ee.Date(image.get('system:time_start')).format("YYYY-MM-dd")
    date = ee.Date(date)
    return image.set('date', date)

col1_date = col1.map(datefunc)
col2_date = col2.map(datefunc)

filterTimeEq = ee.Filter.equals(
    leftField='date',
    rightField='date'
)

simpleJoin = ee.Join.simple()

col_new = ee.ImageCollection(simpleJoin.apply(col1_date, col2_date, filterTimeEq))

有什么辦法可以修改上面的代碼以獲得接近重合的圖像嗎?

解決了! 我使用ee.Filter.maxDifference讓它工作。 我使用了原始'system:time_start'值(以毫秒為單位)並將最大差異設置為一天。 完整代碼如下所示:

filterNear = ee.Filter.maxDifference(
    difference = 86400000,
    leftField='system:time_start',
    rightField='system:time_start'
)

col_near = ee.ImageCollection(simpleJoin.apply(col1, col2, filterNear))

其中 86400000 是 24 小時內的毫秒數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM