-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathunsupervisedPlanetLab.js
48 lines (41 loc) · 1.42 KB
/
unsupervisedPlanetLab.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
/*
This experiment applies unsupervised classification to high resolution
imagery (Planet Lab) of Beirut.
Shunan Feng: [email protected]
*/
var roi =
/* color: #d63000 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[35.48829932537319, 33.911504110472386],
[35.48829932537319, 33.86219806834452],
[35.572070077326316, 33.86219806834452],
[35.572070077326316, 33.911504110472386]]], null, false);
var dataset = ee.ImageCollection('SKYSAT/GEN-A/PUBLIC/ORTHO/RGB')
.filterBounds(roi);
var rgb = dataset.select(['R', 'G', 'B']);
var rgbVis = {
min: 11.0,
max: 190.0,
};
// Map.setCenter(-70.892, 41.6555, 15);
Map.addLayer(rgb, rgbVis, 'RGB');
var image = ee.Image('SKYSAT/GEN-A/PUBLIC/ORTHO/RGB/s02_20150501T075912Z').clip(roi);
// traning
var training = image.sample({
region: roi,
scale: 1,
numPixels: 10000
});
// //-----------------------------------------------------------------//
// // Classification //
// //-----------------------------------------------------------------//
// change the number of classes here, 5 means 5 classes
var clusterer = ee.Clusterer.wekaKMeans(7).train(training);
// // Cluster the input using the trained clusterer.
var classified = image.cluster(clusterer);
Map.addLayer(classified.randomVisualizer(), {}, 'clusters');