Page 70 - รายงานการประยุกต์ใช้ฐานข้อมูลการสำรวจระยะไกลจากซอฟต์แวร์รหัสเปิดและคลาวด์คอมพิวติงเพื่องานพัฒนาที่ดิน Utilization of Remote Sensing Database derived from Open-source software and Cloud computing platform for Land Development
P. 70
ห้องสมุดกรมพัฒนาที่ดิน
62
Code editor 9
// Load a pre-computed Landsat composite for input.
var input = ee.Image('users/totsanatrtk/Ratchaburi_Composite_Visualized_2021');
// Define a region in which to generate a sample of the input.
var region = ee.FeatureCollection("users/totsanatrtk/prov_rachaburi_addmin56");
// Make the training dataset.
var training = input.sample({
region: region,
scale: 30,
numPixels: 5000
});
// Instantiate the clusterer and train it.
var clusterer = ee.Clusterer.wekaKMeans(20).train(training);
// Cluster the input using the trained clusterer.
var result = input.cluster(clusterer);
// Display the clusters with random colors.
Map.addLayer(result.randomVisualizer(), {}, 'clusters');
// Display the sample region.
Map.addLayer(ee.Image().paint(region, 0, 2), {}, 'region');