-
Notifications
You must be signed in to change notification settings - Fork 49
/
inner_joins.py
41 lines (29 loc) · 1.13 KB
/
inner_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
import ee
import geemap
# Create a map centered at (lat, lon).
Map = geemap.Map(center=[40, -100], zoom=4)
# Make a date filter to get images in this date range.
dateFilter = ee.Filter.date('2014-01-01', '2014-02-01')
# Load a MODIS collection with EVI data.
mcd43a4 = ee.ImageCollection('MODIS/MCD43A4_006_EVI') \
.filter(dateFilter)
# Load a MODIS collection with quality data.
mcd43a2 = ee.ImageCollection('MODIS/006/MCD43A2') \
.filter(dateFilter)
# Define an inner join.
innerJoin = ee.Join.inner()
# Specify an equals filter for image timestamps.
filterTimeEq = ee.Filter.equals(**{
'leftField': 'system:time_start',
'rightField': 'system:time_start'
})
# Apply the join.
innerJoinedMODIS = innerJoin.apply(mcd43a4, mcd43a2, filterTimeEq)
# Display the join result: a FeatureCollection.
print('Inner join output:', innerJoinedMODIS)
# Map a function to merge the results in the output FeatureCollection.
joinedMODIS = innerJoinedMODIS.map(lambda feature: ee.Image.cat(feature.get('primary'), feature.get('secondary')))
# Print the result of merging.
print('Inner join, merged bands:', joinedMODIS.getInfo())
# Display the map.
Map