-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandbox.js
92 lines (77 loc) · 3.34 KB
/
sandbox.js
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
/**** Start of imports. If edited, may not auto-convert in the playground. ****/
var bufferMask = ee.Image("users/jrt/final/bufferMask"),
noaaMask = ee.Image("users/jrt/final/noaaMask"),
bufferedShoreline = ee.FeatureCollection("users/jrt/final/bufferedShoreline");
/***** End of imports. If edited, may not auto-convert in the playground. *****/
/**
* Final Project: sandbox module
* Joseph R. Tricarico
* Rutgers School of Environmental and Biological Sciences
* 573:462 Advanced Geomatics
* Dr. Richard G. Lathrop
* May 10, 2021
*
* @fileoverview A place to visualize/experiment with saved assets
* This is also where the analysis samples are generated.
*
**/
var vis = require('users/jrt/gee:final/vis.js');
// import assets not in imports section
var SUFFIX = '_0509_0135'; //MMdd_hhmm
var classified1 = ee.Image('users/jrt/classified1' + SUFFIX);
var classified2 = ee.Image('users/jrt/classified2' + SUFFIX);
var changeSup = ee.Image('users/jrt/changeSup' + SUFFIX);
// var changeSupUnmasked = ee.Image('users/jrt/changeSupUnmasked' + SUFFIX);
// show assets so we know what we're working with
Map.addLayer(noaaMask, {palette: 'blue'}, 'noaaMask', false);
Map.addLayer(bufferMask, {palette: 'yellow'}, 'bufferMask', false);
Map.addLayer(classified1, vis.params.binary, 'classified1', false);
Map.addLayer(classified2, vis.params.binary, 'classified2', false);
Map.addLayer(changeSup, vis.params.s2ShoreChange, 'changeSup', false);
// Map.addLayer(changeSupUmasked, vis.params.s2ShoreChange, 'changeSupUnmasked');
Map.centerObject(changeSup);
// make animated GIF
var years = ee.ImageCollection([classified1, classified2]);
years.getVideoThumbURL({
min: 0,
max: 1,
dimensions: 1080,
framesPerSecond: 1,
},
function(url) {print("Animated GIF:", url);});
// make histogram chart
var changeSupUnmasked = changeSup.unmask();
Map.addLayer(changeSupUnmasked, {}, 'changeSupUnmasked', false);
// var changeSupSample = changeSupUnmasked.sample({
// dropNulls: false, // don't get rid of the unchanged places!
// numPixels: 10e5, // should be enough
// region: bufferedShoreline,
// });
// print('changeSupSample', changeSupSample);
// var histo = ui.Chart.feature.histogram(
// changeSupSample, 'classification', 3, 1);
// print('Sup. Classification Sample Histogram', histo);
var changeSupSSampleNoStyle = changeSupUnmasked.stratifiedSample({
numPoints: 30,
classBand: 'classification',
geometries: true,
region: bufferedShoreline,
});
Export.table.toAsset(changeSupSSampleNoStyle, "changeSupSSampleNoStyle");
var palette = ee.List(['red', 'gray', 'green']);
changeSupSSample = changeSupSSampleNoStyle.map(function(f){
var index = ee.Number(f.get('classification')).add(1);
var color = palette.get(index);
var style = {color: color};
f = f.set('style', style);
return f;
});
var changeSupSSampleImg = changeSupSSample.style({styleProperty: "style"});
Export.table.toAsset(changeSupSSample, "changeSupSSampleNoStyle");
Export.image.toAsset(changeSupSSampleImg, "changeSupSSampleImg");
print('changeSupSSample3', changeSupSSample);
Map.addLayer(changeSupSSampleImg, {}, 'changeSupSSampleImg', false);
// var histo = ui.Chart.feature.histogram(
// changeSupSSample, 'classification', 3, 1);
// print('Sup. Classification Stratified Sample Histogram', histo);
// Map.addLayer(changeSupSSample.draw(), {color: 'red'}, 'changeSupSSample');