-
Notifications
You must be signed in to change notification settings - Fork 50
/
save_best_joins.py
36 lines (27 loc) · 919 Bytes
/
save_best_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
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': GRIDMET meteorological data
gridmet = ee.ImageCollection('IDAHO_EPSCOR/GRIDMET')
# Define a max difference filter to compare timestamps.
maxDiffFilter = ee.Filter.maxDifference(**{
'difference': 2 * 24 * 60 * 60 * 1000,
'leftField': 'system:time_start',
'rightField': 'system:time_start'
})
# Define the join.
saveBestJoin = ee.Join.saveBest(**{
'matchKey': 'bestImage',
'measureKey': 'timeDiff'
})
# Apply the join.
landsatMet = saveBestJoin.apply(primary, gridmet, maxDiffFilter)
# Print the result.
print(landsatMet.getInfo())
# Display the map.
Map