![](/img/trans.png)
[英]Convert RGB image to single band grayscale image within Google Earth Engine using Python API
[英]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.