-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNEON_SJR_MODIS_LST.txt
More file actions
127 lines (105 loc) · 4.57 KB
/
Copy pathNEON_SJR_MODIS_LST.txt
File metadata and controls
127 lines (105 loc) · 4.57 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//Pulling MODIS LST data for a collection of NEON points
//16 January 2024
//Cat Lippi
//Modded by S.J. Ryan, July 2024 for VByte Workshop
//Bring in MODIS LST imagery
var modis = ee.ImageCollection('MODIS/061/MOD11A2').filterDate('2018', Date.now());
var modis_lst = modis.select('LST_Day_1km');
var modis_lst_vis = {
min: 13000.0,
max: 16500.0,
palette: [
'040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
'0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
'3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
'ff0000', 'de0101', 'c21301', 'a71001', '911003'
],
};
//Add MODIS imagery to map
Map.addLayer(modis_lst, modis_lst_vis,
'MODIS LST', false);
// Rescale MODIS LST and convert to Celsius (C)
var modis_lst_C = modis_lst.map(function(image) {
return image
.multiply(0.02)
.subtract(273.15)
.copyProperties(image, ['system:time_start']);
});
///////////////////////////////////////////////////////////////////////////
//FUNCTIONS//
//////////////////////////////////////////////////////////////////////////
// Function to create buffer around each point
function bufferPoints(radius, bounds) {
return function(pt) {
pt = ee.Feature(pt);
return bounds ? pt.buffer(radius).bounds() : pt.buffer(radius);
};
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//Trying to export LST values for all NEON points at once
// Pull in points and make FeatureCollection
// Combine NEON points into one feature collection
var towers = ee.FeatureCollection([
ee.Feature(ee.Geometry.Point([-81.99343, 29.68927]), {plot_id: 'OSBS'}),
ee.Feature(ee.Geometry.Point([-71.28731, 44.06388]), {plot_id: 'BART'}),
ee.Feature(ee.Geometry.Point([-78.07164, 39.06026]), {plot_id: 'BLAN'}),
ee.Feature(ee.Geometry.Point([-76.56001, 38.89008]), {plot_id: 'SERC'}),
ee.Feature(ee.Geometry.Point([-81.4362, 28.12504]), {plot_id: 'DSNY'}),
ee.Feature(ee.Geometry.Point([-84.46861, 31.19484]), {plot_id: 'JERC'}),
ee.Feature(ee.Geometry.Point([-83.50195, 35.68896]), {plot_id: 'GRSM'}),
ee.Feature(ee.Geometry.Point([-80.52484, 37.37828]), {plot_id: 'MLBS'}),
ee.Feature(ee.Geometry.Point([-72.17266, 42.5369]), {plot_id: 'HARV'}),
ee.Feature(ee.Geometry.Point([-78.1395, 38.89292]), {plot_id: 'SCBI'}),
ee.Feature(ee.Geometry.Point([-89.53725, 46.23388]), {plot_id: 'UNDE'}),
ee.Feature(ee.Geometry.Point([-84.2826, 35.96412]), {plot_id: 'ORNL'}),
ee.Feature(ee.Geometry.Point([-87.39327, 32.95046]), {plot_id: 'TALL'}),
]);
//Read in tick plots from 13 NEON sites
//Uploaded csv to Assets
//NOTE: Yours will be named for your asset collection, so change the below variable assignment
var tickplots = ee.FeatureCollection('projects/ee-sjryan3/assets/NEON_tickplots_13sites_utf8');
//view feature collections
Map.addLayer(towers, {color: 'Red'}, 'NEON Towers');
Map.addLayer(tickplots, {color: 'Green'}, 'NEON Tick Plots');
// Implement buffer function to make each point a 1km^2 polygon
var ptsbuff = towers.map(bufferPoints(500, true)); //true = square pixel
var tickbuff = tickplots.map(bufferPoints(500, true));
//Get zonal statistics
var towreduced = modis_lst_C.map(function(image){
return image.reduceRegions({
collection:ptsbuff,
reducer:ee.Reducer.mean(),
scale: 1000 //Resolution of MODIS LST (m)
});
});
print(towreduced.limit(50));
var tickreduced = modis_lst_C.map(function(image){
return image.reduceRegions({
collection:tickbuff,
reducer:ee.Reducer.mean(),
scale: 1000 //Resolution of MODIS LST (m)
});
});
print(tickreduced.limit(50));
// the resulting mean is a FeatureCollection
// so you can export it as a table
//NOTE: when you run the export script, it does not automatically write the file
//after running script, the task tab will highlight in the right GEE editor window
//need to click the run button under unsubmitted tasks for each csv file
Export.table.toDrive({
collection: towreduced.flatten(),
description: 'NEON_towers_MODIS_LST_export',
folder: 'NEON_MODIS',
fileFormat: 'CSV'
})
Export.table.toDrive({
collection: tickreduced.flatten(),
description: 'NEON_tickplots_MODIS_LST_export',
folder: 'NEON_MODIS',
fileFormat: 'CSV'
})
//var table = reduced.flatten();
// Print in console
//print(table.limit(50));