top of page

Yujin Kim, PhD

Image Classification with the Google Earth Engine

Unsupervised Image Classification, Using JavaScript

Aim

– K-Means Clustering

The aim of this task is to classify London’s Sentinel image into clusters of pixels with similar characteristics. Google Earth Engine [1] – an online geospatial analysis platform – was used as it runs relatively fast, is based on Google Cloud processing and provides numerous historical imageries and datasets [2]. This section shows K-means clustering for image classification, using JavaScript.

K-Means Clustering Using JavaScript

Fig. 2.1 is JavaScript that I wrote to run K-means clustering by referencing Google Earth Engine guides [3].

Fig. 2.1. JavaScript programming code

Results from the Image Classification

A Sentinel image of London [4] (Fig. 2.2) was clustered into 10, 50 and 200 categories by K-means image classification (Fig. 2.3, 2.4 and 2.5). For processing, the number of clusters was indicated as 10, 50 and 200 clusters (var nClusters = x in row 21 of the JavaScript code in Fig. 2.1), and other variables remained the same (in rows 22–33 of the JavaScript) for the three implementations to compare their results.

Fig. 2.2. London’s Sentinel image during the period of 1–31 July 2019 [4] in true colour expression (Bands [B4, B3, B2])

Fig. 2.3. Classified image: number of clusters 10 using Google Earth Engine

Fig. 2.4. Classified image: number of clusters 50 using Google Earth Engine

Fig. 2.5. Classified image: number of clusters 200 using Google Earth Engine

When the three results were compared, the River Thames became distinguishable when the number of clusters increased from 10 to 200. This indicates that the pixels composed of the River Thames had more common features with each other in the River Thames’ classification (compared to those of buildings, roads, etc.); thus, the River Thames was represented conspicuously. Parks and clouds were also detectable when the number of clusters increased, although they were less visible with cluster number 200. However, the built environments, including buildings, roads and railways, became invisible when the number of clusters was 200, as their image pixels had various features.

For future studies, this K-means clustering can be used to detect the perimeter changes of the River Thames. When a number of historical Sentinel imageries are collected (e.g. from 1990 to 2023) and classified using this machine learning, how much the River Thames area has changed during a specific period can be quantified. When the image clustering is processed, the increase in clustering number may help because the River Thames becomes more distinguishable.

Another approach is supervised machine learning, which processes based on a labelled training dataset – the user defines the labels – while unsupervised machine learning relies on unlabelled data [5]. The next section introduces a supervised machine learning task.

References

[1] Google Earth Engine, https://earthengine.google.com/.
[2] Advantages and disadvantages of Google Earth Engine,
https://www.earthblox.io/blog/advantages-and-disadvantages-of-google-earth-engine.
[3] JavaScript and Python Guides, https://developers.google.com/earth-engine/guides
[4] Sentinel-2 MSI: MultiSpectral Instrument, Level-2A. Dataset provider: European Union/ESA/Copernicus.
https://developers.google.com/earth-engine/datasets/catalog/COPERNICUS_S2_SR.
[5] Supervised vs. unsupervised learning: what’s the difference?,
https://cloud.google.com/discover/supervised-vs-unsupervised-learning#:~:text=The%20biggest%20difference%20between%20supervised,correct%20output%20values%20should%20be.

bottom of page