-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy path010-modis_zonal_statistics_calculation.js
More file actions
35 lines (28 loc) · 1.07 KB
/
Copy path010-modis_zonal_statistics_calculation.js
File metadata and controls
35 lines (28 loc) · 1.07 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
/*
Author: René Kopeinig
Script: MODIS regional or zonal statistics calculation
Description: Regional or zonal statistics calculation based on a MODIS Net Primary Productivity
for MODIS LandCover class 'Mixed forest'
Version: 0.1
*/
// Feature Collection for area of interest
var fc = ee.FeatureCollection(3513341).filter(ee.Filter.or(ee.Filter.eq('Country','Mexico')));
// MODIS Net Primary Productivity Yearly
var mod17_2001 = ee.Image('MODIS/006/MOD17A3H/2001_01_01').select(0)
// MODIS LandCover Type Yearly
var mod51_2001 = ee.Image('MODIS/051/MCD12Q1/2001_01_01').select(0)
// Masking
var modis_2001_class_1 = mod17_2001.mask(mod51_2001.eq(5))
// Regional/Zonal statistic calculation
function region_stats(input, geom){
var stats_dictionary = input.reduceRegion({
// Reducer could be min, max, mean, stdev
reducer: ee.Reducer.mean(),
geometry: geom.geometry(),
scale: 500,
maxPixels: 1e9
});
return stats_dictionary.getInfo();
}
var mean_2001_class = region_stats(modis_2001_class_1, fc)
console.log(['Mexico',mean_2001_class['Npp']])