-
Notifications
You must be signed in to change notification settings - Fork 49
/
save_all_joins.py
48 lines (38 loc) · 1.24 KB
/
save_all_joins.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import ee
import geemap
# Create a map centered at (lat, lon).
Map = geemap.Map(center=[40, -100], zoom=4)
# Load a primary 'collection': Landsat imagery.
primary = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA') \
.filterDate('2014-04-01', '2014-06-01') \
.filterBounds(ee.Geometry.Point(-122.092, 37.42))
# Load a secondary 'collection': MODIS imagery.
modSecondary = ee.ImageCollection('MODIS/006/MOD09GA') \
.filterDate('2014-03-01', '2014-07-01')
# Define an allowable time difference: two days in milliseconds.
twoDaysMillis = 2 * 24 * 60 * 60 * 1000
# Create a time filter to define a match as overlapping timestamps.
timeFilter = ee.Filter.Or(
ee.Filter.maxDifference(**{
'difference': twoDaysMillis,
'leftField': 'system:time_start',
'rightField': 'system:time_end'
}),
ee.Filter.maxDifference(**{
'difference': twoDaysMillis,
'leftField': 'system:time_end',
'rightField': 'system:time_start'
})
)
# Define the join.
saveAllJoin = ee.Join.saveAll(**{
'matchesKey': 'terra',
'ordering': 'system:time_start',
'ascending': True
})
# Apply the join.
landsatModis = saveAllJoin.apply(primary, modSecondary, timeFilter)
# Display the result.
print('Join.saveAll:', landsatModis.getInfo())
# Display the map.
Map