• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jul 22nd, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD');
2. var poly = ee.Geometry.Polygon(
3.         [[[-95.83648681640625, 29.561512529746743],
4.           [-95.042724609375, 29.57345707301757],
5.           [-95.02899169921875, 30.099989515377835],
6.           [-95.82275390625, 30.10711788709236]]]);
7. var spatialFiltered = sentinel1.filter(ee.Filter.eq('instrumentMode', 'IW')).filterBounds(poly)
9.                                .select('VV');
10. var image = spatialFiltered.filterDate('2017-08-25', '2017-09-05').mosaic().clip(poly);
11. print (image);
12.
13. //Extended Directional Smoothing
14. function eds(image) {
15.   // Create a list of weights for a 3x3 kernel.
16.   var dir1 = ee.List([[0, 0, 0], [0.5, 0, 0.5], [0, 0, 0]]);
17.   var dir2 = ee.List([[0, 0.5, 0], [0, 0, 0], [0, 0.5, 0]]);
18.   var dir3 = ee.List([[0, 0, 0.5], [0, 0, 0], [0.5, 0, 0]]);
19.   var dir4 = ee.List([[0.5, 0, 0], [0, 0, 0], [0, 0, 0.5]]);
20.   //Convolve directional kernels with the image
21.   var d1 = image.convolve(ee.Kernel.fixed(3, 3, dir1, -1, -1));
22.   var d2 = image.convolve(ee.Kernel.fixed(3, 3, dir2, -1, -1));
23.   var d3 = image.convolve(ee.Kernel.fixed(3, 3, dir3, -1, -1));
24.   var d4 = image.convolve(ee.Kernel.fixed(3, 3, dir4, -1, -1));
25.   //Absolute value of the difference from convolved image with original values
26.   var D1=(d1.subtract(image)).abs();
27.   var D2=(d2.subtract(image)).abs();
28.   var D3=(d3.subtract(image)).abs();
29.   var D4=(d4.subtract(image)).abs();
30.   //Pick min pixel value based on abs difference(first input) using reducers
31.   var Dd=ee.ImageCollection([[D1,d1],[D2,d2],[D3,d3],[D4,d4]]);
32.   var reducer =ee.Reducer.min(2);
33.   //Select the second input to the reducer
34.   var v = Dd.reduce(reducer).select('min1');
35.   return v;
36. }
37.
38.
39.
40. function msd(denoised,original) {
41.   var diff = denoised.subtract(original);
42.   var sq= diff.pow(2);
43.   var meanDict = sq.reduceRegion({
44.   reducer: ee.Reducer.mean(),
45.   geometry: poly,
46.   scale: 20 ,
47.   bestEffort:true
48.   });
49.   return meanDict;
50.
51. }
52.
53. //plane smoothing to remove speckle noise
54. var smooth = ee.Image(image.focal_median(100, 'circle', 'meters'));
55. var image_spk = eds(image);
56.
57.
58. print (image_spk);
59. Map.centerObject(poly, 10);
60.