The Basics of Machine Learning in Earth Observation: An Introductory Guide.
Last Updated on June 13, 2024 by Editorial Team
Author(s): Stephen Chege-Tierra Insights
Originally published on Towards AI.
The earth is a beautiful place with wonders and mysteries that can only be comprehended by a closer look, if you believe in the Big Bang, religion, astrology or none of the above- you can never deny we humans know little of what this earth is capable. We will always be one step behind in understanding the details and intricacies of this sphere.
Technology has made it easier to identify features and trends regarding the earth, with satellites deployed that capture earth imagery and beam it back to us humans for further analysis and understanding.
This has seen a rapid increase in the past 60 years with the help of such advanced technologies like drones and planes, we as humans have been able to predict weather patterns and monitor the global climate crises.
However, the development of machine learning and Artificial intelligence has made earth observation much more exhilarating and practical, transforming the way large volumes of data are processed and interpreted to enable better predictions and environmental decision-making. Eventually, this convergence of state-of-the-art technology has contributed to a more robust and informed global community by improving our understanding of and capacity to mitigate the effects of climate change. It also generates breakthroughs for sustainable development and catastrophe management.
What is Earth Observation?
According to the European Agency Space Programme EO or Earth Observation is the process of gathering data about the Earthβs surface, oceans, and atmosphere by satellite, airplane, and/or ground-based remote sensing devices.
The gathered data are processed and analyzed to derive several types of information that can be used to monitor and evaluate changes in the natural and man-made surroundings.
Applications and sectors that use EO data are extremely diverse and include energy, managing urban areas, agriculture, forestry, fisheries, health, transportation, climate change, sustainable development, civil protection, tourism, and more.
According to the UK government Space agence, satellite EO is the process of obtaining data about the Earth by using a range of satellite-based imaging tools, such as atmospheric, radar, optical, and altimeter instruments. Compared to other ground-based data collection techniques, satellite observation of the Earth offers a distinct advantage.
Why is Earth Observation Important?
1. Emergency Disaster Management: To anticipate, track, and effectively respond to natural disasters, including hurricanes, earthquakes, floods, and wildfires, Earth observation systems offer real-time data. This can enhance readiness and reaction plans, prevent financial losses, and save lives.
2. Environmental Protection: Earth observation helps in efforts to manage and conserve natural resources by keeping an eye on biodiversity, deforestation, land use, and water quality. It aids in evaluating the condition of ecosystems and locating regions that need to be restored or conserved.
3. Agriculture and Food Security: Crop health, soil moisture content, and meteorological conditions are tracked using satellite photography and remote sensing technologies. Enhancing crop yields, guaranteeing food security, and optimizing agricultural methods are all made possible by this knowledge.
4. Scientific exploration: By offering extensive data sets that aid in comprehending a variety of natural processes and phenomena, from ocean currents to atmospheric dynamics, it aids a broad range of scientific discovery.
5. Governance and Policy Making: At the municipal, state, and federal levels, decisions on public policy are influenced by timely and accurate earth observation data. It offers the body of data required to develop environmental laws, rules, and programs that work.
Earth Observation and Machine Learning
Machine learning and earth observation are a match made in heaven (pun intended), the two combined forces can unravel insights that the naked eye can never see. You can make predictions and historical patterns.
Large-scale satellite data can be analyzed by machine learning algorithms, which can identify minute variations and patterns and provide previously unheard-of forecasting and monitoring precision. In the end, this potent combination opens the door for more sustainable practices in resource management, disaster response, and environmental protection.
Best Algorithm for Earth Observation and Machine Learning
Use Case: Classification and regression tasks.
Strengths: High dimensionality, huge datasets can be handled by Random Forests due to their robustness. They are frequently employed for classifying land cover, forecasting agricultural yields, and finding trends in environmental data.
// Initialize the Earth Engine API.
var ee = require('ee');
// Authenticate and initialize the client library.
ee.initialize();
// Define the region of interest (ROI).
var roi = ee.Geometry.Rectangle([73.0, 18.0, 74.0, 19.0]);
// Load a Sentinel-2 image collection.
var collection = ee.ImageCollection('COPERNICUS/S2')
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(roi)
.median()
.clip(roi);
// Select the relevant bands for classification.
var bands = ['B2', 'B3', 'B4', 'B8']; // Blue, Green, Red, NIR
// Load a training dataset (points with known land cover types).
var trainingPoints = ee.FeatureCollection([
ee.Feature(ee.Geometry.Point([73.5, 18.5]), {'landcover': 0}), // Example points
ee.Feature(ee.Geometry.Point([73.6, 18.6]), {'landcover': 1}),
// Add more training points as needed
]);
// Sample the Sentinel-2 image at the training points.
var training = collection.select(bands).sampleRegions({
collection: trainingPoints,
properties: ['landcover'],
scale: 10
});
// Train a Random Forest classifier.
var classifier = ee.Classifier.smileRandomForest(10).train({
features: training,
classProperty: 'landcover',
inputProperties: bands
});
// Classify the image.
var classified = collection.select(bands).classify(classifier);
// Define visualization parameters.
var visParams = {
min: 0,
max: 1,
palette: ['red', 'green']
};
// Display the classified image.
Map.centerObject(roi, 10);
Map.addLayer(classified, visParams, 'Land Cover Classification');
// Print the classified image to the console.
print('Classified Image', classified);
2. K-Means
Use Case: Activities involving unsupervised learning.
Strengths: K-Means works well for segmenting and clustering tasks, like classifying similar regions in satellite pictures and recognizing various types of land cover.
// Initialize the Earth Engine API.
var ee = require('ee');
// Authenticate and initialize the client library.
ee.initialize();
// Define the region of interest (ROI).
var roi = ee.Geometry.Rectangle([73.0, 18.0, 74.0, 19.0]);
// Load a Sentinel-2 image collection.
var collection = ee.ImageCollection('COPERNICUS/S2')
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(roi)
.median()
.clip(roi);
// Select the relevant bands for clustering.
var bands = ['B2', 'B3', 'B4', 'B8']; // Blue, Green, Red, NIR
// Prepare the image by selecting the bands.
var image = collection.select(bands);
// Define the number of clusters.
var numClusters = 5;
// Perform K-Means clustering.
var training = image.sample({
region: roi,
scale: 10,
numPixels: 5000
});
var clusterer = ee.Clusterer.wekaKMeans(numClusters).train(training);
var result = image.cluster(clusterer);
// Define visualization parameters.
var visParams = {
min: 0,
max: numClusters - 1,
palette: ['red', 'green', 'blue', 'yellow', 'purple']
};
// Display the clustered image.
Map.centerObject(roi, 10);
Map.addLayer(result, visParams, 'K-Means Clustering');
// Print the clustered image to the console.
print('Clustered Image', result);
3. KNN, or K-Nearest Neighbors
Use Case:
Classification: Based on the majority class of their closest neighbors, new data points are assigned class labels.
Regression: Calculating the average of the values of the closest neighbors to predict continuous values.
Finding anomalous data points by measuring their separation from the closest neighbors is known as anomaly detection.
// Initialize the Earth Engine API.
var ee = require('ee');
// Authenticate and initialize the client library.
ee.initialize();
// Define the region of interest (ROI).
var roi = ee.Geometry.Rectangle([73.0, 18.0, 74.0, 19.0]);
// Load a Sentinel-2 image collection.
var collection = ee.ImageCollection('COPERNICUS/S2')
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(roi)
.median()
.clip(roi);
// Select the relevant bands for clustering.
var bands = ['B2', 'B3', 'B4', 'B8']; // Blue, Green, Red, NIR
// Prepare the image by selecting the bands.
var image = collection.select(bands);
// Define the number of clusters.
var numClusters = 5;
// Perform K-Means clustering.
var training = image.sample({
region: roi,
scale: 10,
numPixels: 5000
});
var clusterer = ee.Clusterer.wekaKMeans(numClusters).train(training);
var result = image.cluster(clusterer);
// Define visualization parameters.
var visParams = {
min: 0,
max: numClusters - 1,
palette: ['red', 'green', 'blue', 'yellow', 'purple']
};
// Display the clustered image.
Map.centerObject(roi, 10);
Map.addLayer(result, visParams, 'K-Means Clustering');
// Print the clustered image to the console.
print('Clustered Image', result);
4. SVMs, or support vector machines:
Use Case: Classification and regression tasks.
Strengths: SVMs work well for applications like change detection and land use classification and are useful for smaller datasets. When the classes are well divided, they are especially helpful.
// Initialize the Earth Engine API.
var ee = require('ee');
// Authenticate and initialize the client library.
ee.initialize();
// Define the region of interest (ROI).
var roi = ee.Geometry.Rectangle([73.0, 18.0, 74.0, 19.0]);
// Load a Sentinel-2 image collection.
var collection = ee.ImageCollection('COPERNICUS/S2')
.filterDate('2020-01-01', '2020-12-31')
.filterBounds(roi)
.median()
.clip(roi);
// Select the relevant bands for classification.
var bands = ['B2', 'B3', 'B4', 'B8']; // Blue, Green, Red, NIR
// Load a training dataset (points with known land cover types).
var trainingPoints = ee.FeatureCollection([
ee.Feature(ee.Geometry.Point([73.5, 18.5]), {'landcover': 0}), // Example points
ee.Feature(ee.Geometry.Point([73.6, 18.6]), {'landcover': 1}),
// Add more training points as needed
]);
// Sample the Sentinel-2 image at the training points.
var training = collection.select(bands).sampleRegions({
collection: trainingPoints,
properties: ['landcover'],
scale: 10
});
// Train an SVM classifier.
var classifier = ee.Classifier.libsvm().train({
features: training,
classProperty: 'landcover',
inputProperties: bands
});
// Classify the image.
var classified = collection.select(bands).classify(classifier);
// Define visualization parameters.
var visParams = {
min: 0,
max: 1,
palette: ['red', 'green']
};
// Display the classified image.
Map.centerObject(roi, 10);
Map.addLayer(classified, visParams, 'Land Cover Classification');
// Print the classified image to the console.
print('Classified Image', classified);
To conclude, K-Nearest Neighbors (KNN) provides an easy-to-use and adaptable method for Earth observation and machine learning, demonstrating exceptional performance in tasks including environmental monitoring, change detection, and land cover classification. KNN is an important tool in the area despite its limits in terms of computational complexity and scalability because of its ease of use and efficiency in collecting local data structures.
Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.
Published via Towards AI