Google Earth Engine (GEE) Functions -
Detailed Guide
1. ImageCollection Functions
These functions are used to load and filter satellite image collections such as Landsat or
Sentinel.
- ee.ImageCollection(collection_id):
Loads a collection of satellite images.
Example:
var collection = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2");
- .filterDate(start, end):
Filters images by date range.
Example:
collection.filterDate('2022-01-01', '2022-12-31');
- .filterBounds(geometry):
Filters images that intersect a specific geometry (region).
Example:
collection.filterBounds(rajshahi);
- .filter(ee.Filter...):
Applies property-based filtering (e.g., cloud cover less than 10%).
Example:
collection.filter(ee.Filter.lt('CLOUD_COVER', 10));
- .sort(property):
Sorts images by a specific property (e.g., cloud cover).
Example:
collection.sort('CLOUD_COVER');
- .first():
Selects the first image from the collection.
Example:
var image = collection.first();
- .median(), .mean(), .min(), .max():
Creates composite images by aggregating pixel values across time.
Example:
var medianImage = collection.median();
2. Image Functions
These functions are used to manipulate and analyze individual satellite images.
- .select(bands):
Selects specific bands from an image.
Example:
image.select(['SR_B4', 'SR_B3', 'SR_B2']);
- .clip(geometry):
Clips the image to a specific geographic area.
Example:
image.clip(rajshahi);
- .normalizedDifference([band1, band2]):
Computes indices such as NDVI or NDWI.
Example:
var ndvi = image.normalizedDifference(['SR_B5', 'SR_B4']).rename('NDVI');
- .multiply(), .add(), .subtract(), .divide():
Performs arithmetic operations on pixel values.
Example:
image.select('SR_B4').multiply(0.0001);
3. Map Functions
These functions help visualize data on the Earth Engine map.
- Map.centerObject(geometry, zoom):
Centers the map on a specific object or region.
Example:
Map.centerObject(rajshahi, 8);
- Map.addLayer(image, visParams, name):
Adds an image layer to the map with visualization parameters.
Example:
Map.addLayer(image, {bands: ['SR_B4', 'SR_B3', 'SR_B2'], min: 5000, max: 15000}, 'RGB');
4. Export Functions
These functions export images or data to Google Drive or other platforms.
- Export.image.toDrive():
Exports an image to Google Drive.
Example:
Export.image.toDrive({
image: image.clip(rajshahi),
description: 'landsat_export',
scale: 30,
region: rajshahi.geometry().bounds(),
maxPixels: 1e9
});
5. Geometry & FeatureCollection Functions
These functions are used to create and filter geographic regions.
- ee.Geometry.*:
Creates geometries such as Point, Polygon, Rectangle.
Example:
var point = ee.Geometry.Point([90.4, 23.8]);
- ee.FeatureCollection():
Loads boundary datasets (e.g., divisions, districts).
Example:
var divisions = ee.FeatureCollection("FAO/GAUL_SIMPLIFIED_500m/2015/level1");
- .filter(ee.Filter.eq('property', 'value')):
Filters regions by attribute value.
Example:
var rajshahi = divisions.filter(ee.Filter.eq('ADM1_NAME', 'Rajshahi'));
6. Charting Functions
These functions generate time series charts from image collections.
- ui.Chart.image.series():
Plots a time series graph of an image property over a region.
Example:
var chart = ui.Chart.image.series({
imageCollection: ndviCollection,
region: rajshahi,
reducer: ee.Reducer.mean(),
scale: 30,
xProperty: 'system:time_start'
});
print(chart);
7. Map() and Iterate()
Used to apply functions over each image in a collection.
- .map(function(image) {...}):
Applies a function to each image in a collection.
Example:
var ndviCollection = collection.map(function(image) {
return image.normalizedDifference(['SR_B5', 'SR_B4']).rename('NDVI');
});
- .iterate(function, initial):
Sequentially applies a reducer or function across a collection.
Example:
var total = collection.iterate(function(img, prev) {
return ee.Number(prev).add(ee.Image(img).reduceRegion({
reducer: ee.Reducer.sum(),
geometry: rajshahi,
scale: 30
}).get('SR_B4'));
}, ee.Number(0));