Commit 8c31a108a8b1e8acc984b1404b9779ba152cab4d

Authored by Simon Gascoin
1 parent de5f5127
Exists in master

add two GEE scripts

Showing 2 changed files with 79 additions and 0 deletions   Show diff stats
cloudPatagonia.js 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +// Mean cloud probability over the Northern Patagonia Icefield
  2 +// as shown here: http://www.cesbio.ups-tlse.fr/multitemp/?p=9001
  3 +// simon.gascoin@cesbio.cnes.fr
  4 +
  5 +// NPI region
  6 +var NPI = ee.Geometry.Rectangle([-74.11,-47.59,-72.83,-46.34]);
  7 +Map.centerObject(NPI);
  8 +Map.addLayer(NPI);
  9 +
  10 +// MODIS MOD10A1 collection
  11 +var cf = ee.ImageCollection('MODIS/MOD10A1').filterDate("2001-01-01","2015-01-01")
  12 +.filterBounds(NPI).select('Snow_Cover_Daily_Tile');
  13 +
  14 +// Get cloud mask
  15 +var cfcloud = cf.map(cloudtest);
  16 +
  17 +// Plot cloud probability by DOY
  18 +var ch = ui.Chart.image.doySeriesByRegion(cfcloud, 'Snow_Cover_Daily_Tile',
  19 +NPI, ee.Reducer.mean(),500,ee.Reducer.mean())
  20 +.setChartType('ColumnChart')
  21 + .setOptions({
  22 + title: 'Cloud probability over the NPI between 2000-01-01 and 2015-01-01 from Terra MODIS (overpass time 10:30)',
  23 + vAxis: {minValue: 0,
  24 + title: '%'},
  25 + hAxis: {title: 'Day of year'},
  26 + legend: { position: 'none'},
  27 + fontSize: 20
  28 + });
  29 +
  30 +print(ch);
  31 +
  32 +// Function that returns 1 if cloud 0 otherwise
  33 +function cloudtest(image) {
  34 + return image.eq(50).multiply(100)
  35 + .set('system:time_start', image.get('system:time_start'));
  36 +}
... ...
displacementPatagonia.js 0 → 100644
... ... @@ -0,0 +1,43 @@
  1 +// Displacement map of San Quintin glacier
  2 +// as shown here: http://www.cesbio.ups-tlse.fr/multitemp/?p=9001
  3 +// simon.gascoin@cesbio.cnes.fr
  4 +
  5 +var pt=ee.Geometry.Point([-74.0,-46.86]);
  6 +// Load the two S2 images to be registered.
  7 +var image1 = ee.Image('COPERNICUS/S2/20160723T144933_20160723T210605_T18GWP')
  8 +.select(['B4','B3','B2']);
  9 +var image2 = ee.Image('COPERNICUS/S2/20160819T142752_20160819T205746_T18GWP')
  10 +.select(['B4','B3','B2']);
  11 +var ndsi = ee.Image('COPERNICUS/S2/20160819T142752_20160819T205746_T18GWP')
  12 +.select(['B3','B11']).normalizedDifference();
  13 +var mask = ndsi.gt(0.4).and(image2.select('B4').gt(2000));
  14 +
  15 +// mask out water and rock.
  16 +var image1Orig = image1.updateMask(mask).resample('bicubic');
  17 +var image2Orig = image2.updateMask(mask);
  18 +
  19 +// Determine the displacement by matching only the red bands.
  20 +var image1RedBand = image1Orig.select('B4');
  21 +var image2RedBand = image2Orig.select('B4');
  22 +var displacement = image2RedBand.displacement({
  23 + referenceImage: image1RedBand,
  24 + maxOffset: 100.0,
  25 + patchWidth: 500.0,
  26 + stiffness:5
  27 +});
  28 +
  29 +// Compute image offset and direction.
  30 +var offset = displacement.select('dx').hypot(displacement.select('dy'));
  31 +var angle = displacement.select('dx').atan2(displacement.select('dy'));
  32 +
  33 +// Display offset distance and angle.
  34 +Map.centerObject(pt, 13);
  35 +Map.addLayer(offset, {min:0, max: 100}, 'offset',0);
  36 +Map.addLayer(angle, {min: -Math.PI, max: Math.PI}, 'angle',0);
  37 +Map.addLayer(image1,{min:2000, max: 7000},'Image 1',0);
  38 +Map.addLayer(image2,{min:2000, max: 7000},'Image 2',0);
  39 +Map.addLayer(displacement.select('confidence'), {min:0, max: 1}, 'confidence',0);
  40 +Map.addLayer(displacement.select('dx'), {min:-50, max: 50}, 'dx',0);
  41 +Map.addLayer(displacement.select('dy'), {min:-50, max: 50}, 'dy',0);
  42 +Map.addLayer(offset.visualize({min:0,max:50,palette: ['white', 'yellow', 'red']}),
  43 +{opacity:0.5},'offset');
... ...