daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var modis_landcover = ee.ImageCollection("MODIS/006/MCD12Q1"),
  2. modis_reflectance = ee.ImageCollection("MODIS/006/MOD09GA"),
  3. roi = /* color: #d63000 */ee.Geometry.Polygon(
  4.     [[[37.83249743231477, 11.586900001191903],
  5.       [40.64499743231477, 11.500787248991408],
  6.       [40.16159899481477, 13.943967698396829],
  7.       [38.05222399481477, 13.85865131156253]]]);
  8.  
  9. Map.centerObject(roi,6);
  10.  
  11. // select dates for land cover
  12. var lcSeries=modis_landcover.filterDate('2000-01-01', '2017-12-31');
  13. print('MODIS lc series:', lcSeries);
  14.  
  15. //select dates for reflectance/ndvi
  16. var reflSeries=modis_reflectance.filterDate('2001-01-01', '2001-12-31');
  17. print('MODIS refl series:', reflSeries);
  18.  
  19. var lc=modis_landcover.filterBounds(roi)
  20.                          .filterDate('2010-01-01')
  21.                          .select('LC_Type1');
  22. print('lc filtered per year and type: ',lc);
  23. var refl=modis_reflectance.filterBounds(roi)
  24.                           .filterDate('2010-09-01')
  25.                           .first();
  26.  
  27. // Use the normalizedDifference(A, B) to compute (A - B) / (A + B)
  28. var ndvi=refl.normalizedDifference(['sur_refl_b02','sur_refl_b01']);
  29. // Make a palette: a list of hex strings.
  30. var palette = ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
  31.                '74A901', '66A000', '529400', '3E8601', '207401', '056201',
  32.                '004C00', '023B01', '012E01', '011D01', '011301'];
  33. var palette2=['05450a', '086a10', '54a708', '78d203', '009900', 'c6b044', 'dcd159',
  34.     'dade48', 'fbff13', 'b6ff05', '27ff87', 'c24f44', 'a5a5a5', 'ff6d4c',
  35.     '69fff8', 'f9ffa4', '1c0dff'];
  36.  
  37. var ndvi_roi=ndvi.clip(roi);
  38. var lc_roi=lc.map(function(img) {return img.clip(roi)});
  39. Map.addLayer(ndvi_roi, {min: 0, max: 1, palette: palette}, 'NDVI');
  40. Map.addLayer(lc_roi,{min: 1, max: 17, palette: palette2},'land cover');
  41.  
  42. //area of the region in Km^2
  43. print('Polygon area in km^2: ', roi.area().divide(1000 * 1000));
  44.  
  45.  
  46. // Get the scale of the data from the first band's projection:
  47. var modisScale = refl.select('sur_refl_b01')
  48.     .projection().nominalScale();
  49. print('MODIS scale in meters:', modisScale);
  50.  
  51. var lc_image=lc.first();
  52. var c = lc_image.reduceRegion({
  53.   reducer: ee.Reducer.count(),
  54.   geometry: roi
  55.   });
  56.   print(c);
  57.  
  58. var frequency = lc_image.reduceRegion({
  59.       reducer:ee.Reducer.frequencyHistogram(),
  60.       geometry:roi,
  61.       scale:1000
  62.     });
  63.     print('landcover frequency', frequency.get('LC_Type1'));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top