Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
28 views1 page

Unsupervised Clustering Using Weka

This document describes unsupervised clustering of a Landsat 8 image collection using the k-means algorithm in Google Earth Engine. It loads Landsat data for a region of interest, samples the image to generate training data, runs k-means clustering with 7 clusters, visualizes the resulting clusters on a map, and exports the classified image.

Uploaded by

May Ann Alvaro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views1 page

Unsupervised Clustering Using Weka

This document describes unsupervised clustering of a Landsat 8 image collection using the k-means algorithm in Google Earth Engine. It loads Landsat data for a region of interest, samples the image to generate training data, runs k-means clustering with 7 clusters, visualizes the resulting clusters on a map, and exports the classified image.

Uploaded by

May Ann Alvaro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

ACT 2

// Unsupervised Clustering using wekaKMeans


// on LANDSAT 8 image collection

// Region of interest
// change the coordinates below (xmin,ymin,xmax,ymax)
// a 45km (x) by 20km (y) ROI is manageable (~600kb when exported)
// var reion = ee.Geometry.Rectangle(121.5047, 16.8282,121.9194, 17.0922);

// Load full LANDSAT 8 collection


var landsat = ee.Algorithms.Landsat
.simpleComposite({
collection:ee.ImageCollection('LANDSAT/LC8_LL1T'),
asFloat:true
})
.select('B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7');

// Clip to ROI
var image = landsat.clip(region);

var training = image.sample({


region: region,
scale: 30,
numPixels: 5000
});

var clusterer = ee.Clusterer.wekaKMeans(7).train(training);


// (7) in wekaKMeans is the number of clusters
// and can be changed depending on the need

var vis = {min: 0, max: 10, palette: [


'023B01', 'CE7E45', 'FCD163', '66A000', '207401',
'056201', '004C00', '023B01', '012E01', '011301']};

var result = image.cluster(clusterer);


Map.centerObject(region,14);
Map.addLayer(result,vis);
//Map.addLayer(result.randomVisualizer(vis)); default if paletter is not provided

// Export an image (size: ~600kb)

Export.image.toDrive({
image: result,
region: region,
description: 'classified',
scale: 30
});

You might also like