GEET (Google Earth Engine Toolbox)

August 25, 2026 · View on GitHub

DOI

Google Earth Engine website: https://earthengine.google.com/
JavaScript Code Editor: https://code.earthengine.google.com/
Documentation: https://developers.google.com/earth-engine/
Python API: https://developers.google.com/earth-engine/python_install

Development Info

Author: Eduardo Ribeiro Lacerda - eduardolacerdageo@gmail.com

  • Researcher @ Humboldt-Universität zu Berlin

Introduction:

The Google Earth Engine Toolbox (GEET) is a JavaScript single-file library to help developers write small codebase applications with the Google Earth Engine (GEE) platform.

The library can also be used to teach new developers to use the platform even without any previous programming skills.

GEET using Landsat Collection 2 will be available soon!

ndvi

Documentation:

All functions implemented (Version 1.13.1):

Machine Learning & Classification

Spectral Indices & Transformations

Change Detection

Time Series & Mosaics

Radar

Topography

Pre-Processing & Calibration

Statistics & Math

Visualization, Utilities & Export

Object-Based Image Analysis (GEOBIA)

Harmonized Landsat Sentinel-2 (HLS)


Quickstart Guide:

(English)

To use the library, you need to click on this link. It will automatically add all the code of the library in your Google Earth Engine personal account. You only need to perform this procedure once. Remember that to add the library, you must already have an account on the Earth Engine platform. To know more, visit the official site of the platform: https://earthengine.google.com/

After adding the library, you can call its functions using the function require and store the content in a variable. In this case, we will create a variable called geet which contains all the contents of the library. Then we can use it to call library functions:

    var geet = require('users/eduardolacerdageo/geet:geet'); 
    var image = geet.load_image('TOA', 2015); // Returns and loads an image on the map.

(Português)

Para utilizar a biblioteca, é preciso clicar neste link. Ele adicionará automaticamente todo o código da biblioteca à sua conta pessoal do Google Earth Engine. Só é® necessário realizar este procedimento uma única vez. Lembre-se de que para adicionar a biblioteca é® necessário já possuir uma conta na plataforma do Earth Engine. Para saber mais, visite o site oficial da plataforma: https://earthengine.google.com/

Depois de adicionar a biblioteca ├® poss├¡vel chamar suas fun├º├Áes utilizando a fun├º├úo require e armazenando o conte├║do em uma vari├ível. Neste caso, criaremos uma variável chamada geet que conterá todo o conteúdo da biblioteca. Depois, podemos utilizá-la para chamar as funções da biblioteca:

    var geet = require('users/eduardolacerdageo/geet:geet'); 
    var image = geet.load_image('TOA', 2015); // Carrega uma imagem no mapa.


Machine Learning & Classification


svm

(image, trainingData, fieldName, kernelType, resolution)

Function to apply SVM classification to an image.

Usage:
    var result = geet.svm(image, trainingData, fieldName, kernelType, resolution);   

Params:

(ee.Image) image - The input image to classify.
(FeatureCollection) trainingData - Training data (samples).
optional (string) fieldName - The name of the column that contains the class names.
optional (string) kernelType - the kernel type of the classifier.
optional (number) resolution - the spatial resolution of the input image. Default is 30 (landsat).

Usage:
    var imgClass = geet.svm(image, samplesfc, landcover);   

cart

(image, trainingData, fieldName, resolution)

Function to apply CART classification to an image.

Usage:
    var result = geet.cart(image, trainingData, fieldName, resolution);   

Params:

(ee.Image) image - The input image to classify.
(FeatureCollection) trainingData - Training data (samples).
optional (string) fieldName - The name of the column that contains the class names.
optional (number) resolution - the spatial resolution of the input image. Default is 30 (landsat).

Usage:
    var imgClass = geet.cart(image, samplesfc, landcover);    

rf

(image, trainingData, fieldName, numOfTrees, resolution, cv_split)

Function to apply Random Forest classification to an image.

Usage:
    var result = geet.rf(image, trainingData, fieldName, numOfTrees, resolution, cv_split);   

Params:

(ee.Image) image - The input image to classify.
(array of strings) bands - The input band names that will be chosen to train the model.
(FeatureCollection) trainingData - All the training data (samples).
(string) fieldName - The name of the column that contains the class names.
optional (number) numOfTrees - The number of trees that the model will create. Default is 10.
optional (number) resolution - The spatial resolution of the input image. Default is 30 (Landsat).
optional (number) cv_split - The cross validation split percentage.

Usage:
    var imgClass = geet.rf(image, bands, samplesfc, landcover, 10);   

or

    var imgClass = geet.rf(image, bands, samplesfc, landcover, 10, 30, 0.7);  

naive_bayes

(image, trainingData, fieldName, resolution)

Function to apply the Fast Naive Bayes classification to an image.

Usage:
    var result = geet.naive_bayes(image, trainingData, fieldName, resolution);   

Params:

(ee.Image) image - The input image to classify.
(FeatureCollection) trainingData - Training data (samples).
optional (string) fieldName - The name of the column that contains the class names.
optional (number) resolution - The spatial resolution of the input image. Default is 30 (Landsat).

Usage:
    var imgClass = geet.naive_bayes(image, samplesfc, landcover);    

or

    var imgClass = geet.naive_bayes(image, samplesfc, landcover, 30);  

max_ent

(image, trainingData, fieldName, resolution)

Function to apply the GMO Maximum Entropy classification to an image.

Usage:
    var result = geet.max_ent(image, trainingData, fieldName, resolution);   

Params:

(ee.Image) image - The input image to classify.
(FeatureCollection) trainingData - Training data (samples).
optional (string) fieldName - The name of the column that contains the class names.
optional (number) resolution - The spatial resolution of the input image. Default is 30 (Landsat).

Usage:
    var imgClass = geet.max_ent(image, samplesfc, landcover);   

or

   var imgClass = geet.max_ent(image, samplesfc, landcover, 30);   

kmeans

(image, roi, numClusters, resolution, numPixels)

Function to apply RandomForest classification to an image.

Usage:
    var result = geet.kmeans(image, roi, numClusters, resolution, numPixels);   

Params:

(ee.Image) image - The input image to classify.
(Feature/Geometry) roi - A polygon containing the study area. optional (number) _numClusters - the number of clusters that will be used. Default is 15.
optional (number) _scale - the scale number. The scale relates to the image's spatial resolution. Landsat is 30, so the default is 30 also.
optional (number) _numPixels - the number of pixels that the classifier will take samples from the roi.

Usage:
    var imgClass = geet.kmeans(image, roi);    

or

    var imgClass = geet.kmeans(image, roi, 20, 10, 6000);  



unmix

(image, bands, endmembers, names, sumToOne, nonNegative)

Function to apply Linear Spectral Unmixing (LSU) to an image.

Params:

(ee.Image) image - The input image.
(array of strings) bands - The bands to be unmixed.
(list of lists) endmembers - The endmember spectral signatures.
(array of strings) names - The names for the output fraction bands.
optional (boolean) sumToOne - Constrain fractions to sum to one. Default is false. optional (boolean) nonNegative - Constrain fractions to be non-negative. Default is true.

Usage:
    var unmixed = geet.unmix(image, ['red', 'nir', 'swir1'], [[0.1, 0.2, 0.1], [0.8, 0.9, 0.3]], ['soil', 'veg']);

Spectral Indices & Transformations


landsat_indices

(image, sensor, index)

Function to take an input image and generate indices like: NDVI, NDWI, NDBI...
More indices and features will be added in the future!
Supported indices: NDVI, NDWI, NDBI, NRVI, EVI, SAVI and GOSAVI

Usage:
    var result = geet.landsat_indices(image, sensor, index);   

Params:

(ee.Image) image - the image to process.
(string) sensor - the sensor that you are working on: Landsat 5 ('L5'), 7 ('L7'), and 8 ('L8').
optional (string or string array) index - you can specify the index that you want . If you don't specify any index, the function will create all possible indices.

Usage:
    var result = geet.landsat_indices(image, 'L5'); // Will create all possible indices.  

or specifying the index to generate:

    var result = geet.landsat_indices(image, 'L5', 'savi'); // This will create only SAVI.    

or specifying an array of indices to generate:

    var result = geet.landsat_indices(image, 'L5', ['ndvi', 'evi', 'ndwi']); // Creates only NDVI, EVI, and NDWI.    

sentinel2_indices

(image, index)

Function to take an input image and generate indices using the Sentinel 2 dataset.


Usage:
    var result = geet.sentinel2_indices(image, index);   

water_indices

(image, sensor)

Function to generate advanced water quality indices: NDTI (Normalized Difference Turbidity Index) and NDCI (Normalized Difference Chlorophyll Index).

Usage:
    var result = geet.water_indices(image, sensor);   

Params:

(ee.Image) image - the input image. (string) sensor - 'L8', 'L9' or 'S2'.

Usage:
    var water_img = geet.water_indices(s2_image, 'S2'); 

tasseled_cap

(image, sensor)

Generic function to create a Tasseled Cap image.

Usage:
    var result = geet.tasseled_cap(image, sensor);   

Params:

(ee.Image) image - the input image. (string) sensor - 'L5', 'L7', 'L8', 'L9', or 'S2'.

Usage:
  var image_tcap = geet.tasseled_cap(img, 'L8');  

pca

(image, nbands, scale, maxPixels)

Function produces the principal components analysis of an image.

Usage:
    var result = geet.pca(image, nbands, scale, maxPixels);   

Params:

(ee.Image) image - the input image.
optional (number) nBands - the number of bands of the image. Default is 12.
optional (number) scale - the scale number. The scale relates to the image's spatial resolution. Landsat is 30, so the default is 30 also.
optional (number) maxPixels - the maximum number of pixels that can be exported. Default is 1e10.

Usage:
    var pca = geet.pca(img);
    var pca_image = ee.Image(pca[0]);
    Map.addLayer(pca_image);

ndviS2

(image)

Function that calculates the normalized difference vegetation index (NDVI) from Sentinel 2 data.

Usage:
    var result = geet.ndviS2(image);   

Params:

(ee.Image) image - the input image.

Usage:
    var s2_ndvi = geet.ndviS2(img);



kndvi

(image, nir_band, red_band)

Function to calculate the Kernelized Normalized Difference Vegetation Index (kNDVI).

Params:

(ee.Image) image - The input image.
(string) nir_band - Name of the NIR band.
(string) red_band - Name of the Red band.

Usage:
    var img_kndvi = geet.kndvi(image, 'B4', 'B3');   

fvc

(image, ndvi_band, ndvi_soil, ndvi_veg)

Function to calculate Fractional Vegetation Cover (FVC) based on NDVI endmembers.

Params:

(ee.Image) image - The input image.
(string) ndvi_band - Name of the NDVI band.
optional (number) ndvi_soil - NDVI value for bare soil. Default is 0.15.
optional (number) ndvi_veg - NDVI value for dense vegetation. Default is 0.90.

Usage:
    var img_fvc = geet.fvc(image, 'NDVI', 0.10, 0.85);   

Change Detection


ndvi_change_detection

(img1, img2, sensor, threshold)

Function to detect changes between two input images using the NDVI index and a threshold parameter. The function adds the two masked indices and returns the sum of the two. It's a good choice to call the plot_class function to visualize the result. Ex: geet.plot_class(ndviChange, 3, 'change_detection');

Usage:
    var result = geet.ndvi_change_detection(img1, img2, sensor, threshold);   

Params:

(string) sensor = The name of the sensor that will be used. 'L5' or 'L8.
(ee.Image) img1 = The first input image.
(ee.Image) img2 = The second input image.
(ee.Number) threshold = The number of the threshold. All the values in the image that are greater than or equal to this number will be selected.

Usage:
    var ndviChange = geet.simpleNDVIChangeDetection(image_2014, image_2015, 'L8', 0.5);   

ndwi_change_detection

(img1, img2, sensor, threshold)

Function to detect changes between two input images using the NDWI index and a threshold parameter. The function adds the two masked indices and returns the sum of the two. It's a good choice to call the plot_class function to visualize the result. Ex: geet.plot_class(ndwiChange, 3, 'change_detection');

Usage:
    var result = geet.ndwi_change_detection(img1, img2, sensor, threshold);   

Params:

(string) sensor = The name of the sensor that will be used. 'L5' or 'L8.
(ee.Image) img1 = The first input image.
(ee.Image) img2 = The second input image.
(ee.Number) threshold = The number of the threshold. All the values at the image that are greater than or equal to this number will be selected.

Usage:
    var ndwiChange = geet.ndwi_change_detection( image_2014, image_2015, 'L8', 0.5);  

ndbi_change_detection

(img1, img2, sensor, threshold)

Function to detect changes between two input images using the NDBI index and a threshold parameter. The function adds the two masked indices and returns the sum. It's a good choice to call the plot_class function to visualize the result. Ex: geet.plot_class(ndbiChange, 3, 'change_detection');

Usage:
    var result = geet.ndbi_change_detection(img1, img2, sensor, threshold);   

Params:

(string) sensor = The name of the sensor that will be used. 'L5' or 'L8.
(ee.Image) img1 = The first input image.
(ee.Image) img2 = The second input image.
(ee.Number) threshold = The number of the threshold. All the values at the image that are greater than or equal to this number will be selected.

Usage:
    var ndbiChange = geet.ndbi_change_detection(image_2014, image_2015, 'L8', 0.5);  


Time Series & Mosaics


create_mosaic

(startDate, endDate, roi, showMosaic, sensor)

Generic function to build a cloud-free mosaic for Landsat 5, 7, 8, 9, or Sentinel-2.

Usage:
    var result = geet.create_mosaic(startDate, endDate, roi, showMosaic, sensor);   

Params:

(ee.Date) startDate - the start date of the dataset. (ee.Date) endDate - the end date of the dataset. optional (ee.Geometry) roi - the Region of Interest to filter the dataset. optional (bool) showMosaic - set to false if you don't want to display the mosaic. Default is true. (string) sensor - 'L5', 'L7', 'L8', 'L9' or 'S2'.

Usage:
    var mosaic = geet.create_mosaic('2023-01-01', '2023-12-31', roi, true, 'L8'); 

smooth_timeseries

(collection, windowSize)

Function to apply a moving average filter to smooth a time series of images (e.g., NDVI series).

Usage:
    var result = geet.smooth_timeseries(collection, windowSize);   

Params:

(ee.ImageCollection) collection - the input image collection to smooth. optional (number) windowSize - the moving window size in days. Default is 30.

Usage:
    var smoothed_ndvi = geet.smooth_timeseries(ndvi_collection, 45); 


topographic_correction

(image, dem)

Applies Topographic Illumination Correction to optical images using the Cosine correction method. This is extremely useful for removing terrain shadows in mountainous areas, relying on the solar elevation and azimuth stored in the image's metadata.

Usage:
    var result = geet.topographic_correction(image, dem);   

Params:

(ee.Image) image - the optical image to correct (e.g., Landsat or Sentinel). (ee.Image) dem - (optional) the Digital Elevation Model to use. Defaults to SRTM.

Usage:
  var corrected_img = geet.topographic_correction(landsat_img);

calculate_twi

(roi)

Calculates the Topographic Wetness Index (TWI). This index combines local slope and flow accumulation to quantify topographic control on hydrological processes, making it excellent for identifying wetlands, springs, and water accumulation zones.

Usage:
    var result = geet.calculate_twi(roi);   

Params:

(ee.Geometry) roi - (optional) the region of interest to clip the outputs.

Usage:
  var twi = geet.calculate_twi(roi);
  Map.addLayer(twi, {min: 5, max: 20, palette: ['red', 'yellow', 'green', 'blue']}, 'TWI');

calculate_tpi_tri

(roi)

Calculates the Topographic Position Index (TPI) and Terrain Ruggedness Index (TRI) based on focal mean and focal standard deviation. TPI is used to classify valleys and ridges, while TRI is used to map terrain unevenness.

Usage:
    var result = geet.calculate_tpi_tri(roi);   

Params:

(ee.Geometry) roi - (optional) the region of interest to clip the outputs.

Usage:
  var terrain_indices = geet.calculate_tpi_tri(roi);
  var tpi = terrain_indices.select('TPI');
  var tri = terrain_indices.select('TRI');

extract_drainage

(roi, threshold)

Automatically extracts the drainage/stream network based on a flow accumulation threshold using the HydroSHEDS dataset.

Usage:
    var result = geet.extract_drainage(roi, threshold);   

Params:

(ee.Geometry) roi - (optional) the region of interest. (number) threshold - (optional) the flow accumulation threshold (in pixels) to define a stream. Defaults to 500.

Usage:
  var rivers = geet.extract_drainage(roi, 1000);
  Map.addLayer(rivers, {palette: ['blue']}, 'Drainage Network');

build_annual_mss_timeseries

(roi)

Function to build an annual Landsat MSS (Landsat 1, 2, 3, 4, 5) timeseries from 1972 to 1999. The function normalizes the distinct bands of older satellites into 'GREEN', 'RED', 'NIR1', 'NIR2', masks clouds using QA_PIXEL, calculates NDVI, and generates median annual mosaics.

Usage:
    var result = geet.build_annual_mss_timeseries(roi);   

Params:

(ee.Point) roi - the region of interest that will define the study area

Usage:
    var mss_timeseries = geet.build_annual_mss_timeseries(roi);     

build_annual_landsat_timeseries

(roi)

Function to build an annual Landsat (5, 7, 8, and 9) TOA time series from 1985 to 2030. The function also masks clouds and shadows, normalizes bands to standard English names, and generates all indices (NDVI, NDWI, SAVI, Tasseled Cap).

Usage:
    var result = geet.build_annual_landsat_timeseries(roi);   

Params:

(ee.Point) roi - the region of interest that will define the study area and the Landsat path row

Usage:
    var ls_timeseries = geet.build_annual_landsat_timeseries(roi);     

landsat_timeseries

(sensor, type, path, row)

Generic function to build an annual Landsat timeseries for a specific sensor.

Usage:
    var result = geet.landsat_timeseries(sensor, type, path, row);   

Params:

(string) sensor - 'L5', 'L7', 'L8', 'L9'. (string) type - 'TOA' or 'SR'. (number) path - the WRS-2 path. (number) row - the WRS-2 row.

Usage:
  var l8_ts = geet.landsat_timeseries('L8', 'TOA', 221, 71);

landsat_timeseries_by_pathrow

(type, path, row)

Function that return a image collection with all landsat images (5 and 8) from a defined path row. Remember to specify the type of the collection (raw, toa or sr).

Usage:
    var result = geet.landsat_timeseries_by_pathrow(type, path, row);   

Params:

(string) type - the type of the collection (RAW, TOA or SR)
(number) path - the path number of the image
(number) row - the row number of the image

Usage:
  	var ls_collection = geet.landsat_timeseries_by_pathrow('SR', 217, 76);   

landsat_timeseries_by_roi

(type, path, row)

Function that returns an image collection with all Landsat images (5 and 8) from a defined roi. Remember to specify the type of the collection (raw, toa or sr).

Usage:
    var result = geet.landsat_timeseries_by_roi(type, path, row);   

Params:

(string) type - the type of the collection (RAW, TOA, or SR)
(ee.Geometry) roi - the Region of Interest to filter the dataset

Usage:
    var ls_collection = geet.landsat_timeseries_by_roi('SR', roi); 



stm_features

(collection, reducers)

Generates Spectral-Temporal-Metrics (STM) by applying statistical reducers over an image collection.

Params:

(ee.ImageCollection) collection - The input image collection.
optional (ee.Reducer) reducers - Custom ee.Reducer. If omitted, applies p10, p50, p90, min, max, and stdDev.

Usage:
    var stm = geet.stm_features(my_collection);   

add_doy

(image)

Adds a Day of Year (DOY) band to the image, keeping the original pixel mask.

Params:

(ee.Image) image - The input image.

Usage:
    var img_doy = geet.add_doy(image);   

add_millis

(image)

Adds a milliseconds timestamp band to the image, keeping the original pixel mask.

Params:

(ee.Image) image - The input image.

Usage:
    var img_millis = geet.add_millis(image);   

remove_outliers

(collection, window_days, std_multi, bands)

Applies a moving average and standard deviation filter to remove outliers from a time series.

How it works: Cloud and shadow masking algorithms often fail to detect thin cirrus or small cloud edges, leaving anomalous "spikes" in the data. This function applies an ee.Join.saveAll to gather a rolling window (e.g., 30 days) of imagery around each target pixel. It calculates the temporal mean and standard deviation for that pixel. If the pixel's value falls outside the expected range (e.g., beyond ±3 standard deviations), it is classified as a noisy outlier and masked out, leaving a clean time series trajectory.

Params:

(ee.ImageCollection) collection - The input image collection.
(number) window_days - The rolling window size in days (e.g. 30).
(number) std_multi - The standard deviation multiplier (e.g. 3).
optional (array of strings) bands - The specific bands to mask.

Usage:
    var clean_col = geet.remove_outliers(collection, 30, 3, ['NDVI']);   

tsi_rbf

(collection, window_days, sigma)

Gap-fills and smooths a time series using a Radial Basis Function (RBF) Gaussian kernel over a temporal window.

How it works: Once clouds, shadows, and outliers are removed, a time series is full of data gaps (masked pixels). This function interpolates those gaps using neighboring observations in time. It scans a window_days neighborhood (using ee.Join.saveAll to compute the temporal delta between images) and assigns a Gaussian weight based on the time distance (sigma). Observations closer in time to the gap get a higher weight. It then performs a weighted average to smoothly fill the missing data, rebuilding a continuous, high-quality temporal profile.

Params:

(ee.ImageCollection) collection - The input image collection to gap-fill.
(number) window_days - The rolling window size in days to search for valid pixels.
(number) sigma - The standard deviation of the RBF kernel in days (e.g. 16).

Usage:
    var rbf_col = geet.tsi_rbf(collection, 60, 16);   

phenology_metrics

(collection, band)

Extracts Land Surface Phenology (LSP) metrics (Start of Season, Peak of Season, and Magnitude) by converting a time series to Polar Vectors.

How it works: Extracting phenology in Earth Engine using curve-fitting (like double logistics) is computationally prohibitive on a pixel basis. This function bypasses curve fitting by projecting the time series into a Polar Coordinate system. It translates the Day of Year (DOY) into an angular coordinate, and uses the vegetation index (e.g., NDVI) as the radius. By averaging these polar vectors, the resulting angle (θ) natively points to the Start of Season (SOS), while the opposite angle points to the Peak of Season (POS). The magnitude of the vector indicates the strength of the seasonal amplitude.

Params:

(ee.ImageCollection) collection - The input image collection containing a full seasonal cycle.
(string) band - The index or band to use for phenology extraction (e.g. 'NDVI').

Usage:
    var lsp_img = geet.phenology_metrics(collection, 'NDVI');   

tsi_rbf

(collection, window_days, sigma)

Gap-fills and smooths a time series using a Radial Basis Function (RBF) Gaussian kernel over a temporal window.

Params:

(ee.ImageCollection) collection - The input image collection to gap-fill.
(number) window_days - The rolling window size in days to search for valid pixels.
(number) sigma - The standard deviation of the RBF kernel in days (e.g. 16).

Usage:
    var rbf_col = geet.tsi_rbf(collection, 60, 16);   

phenology_metrics

(collection, band)

Extracts Land Surface Phenology (LSP) metrics (Start of Season, Peak of Season, and Magnitude) by converting a time series to Polar Vectors.

Params:

(ee.ImageCollection) collection - The input image collection containing a full seasonal cycle.
(string) band - The index or band to use for phenology extraction (e.g. 'NDVI').

Usage:
    var lsp_img = geet.phenology_metrics(collection, 'NDVI');   

Radar & Topography


s1_preprocess

(startDate, endDate, roi, polarization, orbit)

Function to load and preprocess Sentinel-1 SAR (Radar) GRD Data.

Usage:
    var result = geet.s1_preprocess(startDate, endDate, roi, polarization, orbit);   

Params:

(ee.Date) startDate - the start date of the dataset. (ee.Date) endDate - the end date of the dataset. optional (ee.Geometry) roi - the Region of Interest. optional (string) polarization - 'VV', 'VH', 'HH', 'HV'. Default is 'VV'. optional (string) orbit - 'DESCENDING' or 'ASCENDING'. Default is 'DESCENDING'.

Usage:
    var radar_img = geet.s1_preprocess('2023-01-01', '2023-12-31', roi, 'VV', 'DESCENDING'); 

speckle_filter

(image, radius)

Function to apply a focal median filter to reduce SAR speckle noise.

Usage:
    var result = geet.speckle_filter(image, radius);   

Params:

(ee.Image) image - the input SAR image. optional (number) radius - the radius of the filter in meters. Default is 30.

Usage:
    var smooth_radar = geet.speckle_filter(radar_img, 50); 

s1_lee_filter

(image, kernel_size)

Applies an adaptive Speckle Filter based on the Lee algorithm to Sentinel-1 images. It preserves edges while smoothing homogeneous areas by computing directional variances.

How it works: The filter converts the radar backscatter from logarithmic (dB) to linear scale. It calculates the local mean and variance within the specified kernel. By using the Equivalent Number of Looks (ENL) and the local coefficient of variation, it creates a dynamic weighting factor. In homogeneous areas (low variance), it heavily applies the local mean to reduce granular noise. Near edges (high variance), it preserves the original pixel values to maintain structural sharpness, before converting the data back to dB.

Params:

(ee.Image) image - The input SAR image. (number) kernel_size - The size of the kernel in pixels (e.g. 3 or 5).

Usage:
    var smooth_radar = geet.s1_lee_filter(radar_img, 3); 

s1_terrain_flattening

(image)

Performs Radiometric Terrain Flattening on Sentinel-1. Converts Sigma0 backscatter to Gamma0, removing topography-induced distortions (like foreshortening) using local incidence angles from the Copernicus 30m DEM.

How it works: Traditional SAR imagery is provided in Sigma Naught (σ°), which assumes the Earth is completely flat. In mountainous areas, slopes facing the radar reflect too much energy (appearing artificially bright), while slopes facing away appear dark. This function calculates the local slope, aspect, and the satellite's specific heading angle. It computes the true local incidence angle for each pixel and calculates a trigonometric flattening factor (tan(α) / tan(θ)) to correct the signal into Gamma Naught (γ°), which is the radiometrically true physical reflectance of the surface regardless of terrain.

Params:

(ee.Image) image - The input SAR image containing an 'angle' band.

Usage:
    var flat_radar = geet.s1_terrain_flattening(radar_img); 

s1_flood_mapping

(image_before, image_after, threshold, smoothing_radius, band)

Detects flooded areas by comparing a pre-flood and post-flood Sentinel-1 image using a thresholding approach. Automatically masks out permanent water bodies using the JRC Global Surface Water dataset.

How it works: Smooth water surfaces act like mirrors (specular reflection), scattering radar pulses away from the satellite, which causes flooded areas to appear very dark in SAR imagery. This function subtracts the pre-flood image from the post-flood image. It applies a focal mean spatial smoothing (to reduce salt-and-pepper noise) and isolates pixels where the backscatter dropped by more than the user-defined threshold (e.g., a drop of -3.0 dB). Finally, it queries the high-resolution JRC Global Surface Water database to subtract historically permanent rivers and lakes from the result, leaving only the newly flooded anomalous areas.

Params:

(ee.Image) image_before - The SAR image before the flood event. (ee.Image) image_after - The SAR image during the flood event. (number) threshold - The backscatter drop threshold in dB (e.g., -3.0). (number) smoothing_radius - The radius in meters to smooth the difference image (e.g., 50). (string) band - The polarization band to use, typically 'VV' or 'VH'.

Usage:
    var flood_mask = geet.s1_flood_mapping(img_pre, img_post, -3.0, 50, 'VV'); 

terrain_analysis

(roi)

Function to generate Elevation, Slope, Aspect, and Hillshade bands from the SRTM 30m DEM.

Usage:
    var result = geet.terrain_analysis(roi);   

Params:

optional (ee.Geometry) roi - the Region of Interest to clip the DEM.

Usage:
    var terrain = geet.terrain_analysis(roi); 
    // Contains bands: 'Elevation', 'Slope', 'Aspect', 'Hillshade'


Pre-Processing & Calibration


toa_radiance

(image, band)

Function to do a band conversion of digital numbers (DN) to Top of Atmosphere (TOA) Radiance.

Usage:
    var result = geet.toa_radiance(image, band);   

Params:

(ee.Image) image - The image to process.
(number) band - The number of the band that you want to process.

Usage:
    var new_toa_radiance = geet.toa_radiance(img, 10); // ee.Image    

toa_reflectance

(image, band, sensor, solarAngle)

Generic function to calculate TOA Reflectance from raw DN.

Usage:
    var result = geet.toa_reflectance(image, band, sensor, solarAngle);   

Params:

(ee.Image) image - the input raw image. (string) band - the band name to process. (string) sensor - 'L5', 'L7', 'L8', or 'L9'. optional (number) solarAngle - solar angle if absent from metadata.

Usage:
  var ref_img = geet.toa_reflectance(raw_img, 'B4', 'L8');

brightness_temp

(image, sensor, unit, two_channel)

Generic function to convert the Top of Atmosphere (TOA Radiance) image to Brightness Temperature.

Usage:
    var result = geet.brightness_temp(image, sensor, unit, two_channel);   

Params:

(ee.Image) image - the TOA Radiance image to convert. (string) sensor - 'L5', 'L7', 'L8' or 'L9' (string) unit - 'K' (Kelvin) or 'C' (Celsius) optional (bool) two_channel - for L8/L9 only, if true, processes both B10 and B11. Default is true.

Usage:
    var bt_img = geet.brightness_temp(toa_rad_image, 'L8', 'C'); 

surface_emissivity

(image)

Function calculate the surface emissifity.

Usage:
    var result = geet.surface_emissivity(image);   

Params:

(ee.Image) image - input image with the proportional vegetation band.

Usage:
    var lse = geet.surface_emissivity(pv);

surface_temperature_tm

(image)

Function that calculates the land surface temperature (Landsat 5).

Usage:
    var result = geet.surface_temperature_tm(image);   

Params:

(ee.Image) image - the input image with the TOA_Radiance, Brightness_Temperature, NDVI, prop_veg, and LSE bands.

Usage:
    var surfTemp_img = geet.surface_temperature_tm(img);

surface_temperature_oli

(image)

Function calculate the land surface temperature (Landsat 8).

Usage:
    var result = geet.surface_temperature_oli(image);   

Params:

(ee.Image) image - the input image with the TOA_Radiance, Brightness_Temperature, NDVI, prop_veg, and LSE bands.

Usage:
    var surfTemp_img = geet.surface_temperature_oli(img);

calculate_lst

(input)

Unified function to calculate Land Surface Temperature (LST) using the Single-Channel algorithm. It dynamically detects the sensor (Landsat 5, 7, 8, or 9) from the image metadata and applies the correct calibration constants and thermal wavelengths. It supports processing a single image or mapping over an entire ImageCollection (e.g., a time series). Output LST is in Celsius.

Usage:
    var result = geet.calculate_lst(input);   

Params:

(ee.Image | ee.ImageCollection) input - The input image or image collection.

Usage:
  var geet = require('users/eduardolacerdageo/geet:geet'); 
  // For a single image
  var lst_img = geet.calculate_lst(img);
  
  // For a time-series collection!
  var lst_collection = collection.map(geet.calculate_lst);

export_image

(image, scale)

Function to export an image to your Google Drive account.

Usage:
    var result = geet.export_image(image, scale);   

Params:

(ee.Image) image - the input image.
optional (number) _scale - the scale number.The scale relates to the image's spatial resolution. Landsat is 30, so the default is 30 also.

Usage:
    geet.export_image(img);

or

    geet.export_image(sentinel2_img, 10);

load_image

(collection, year, roi, cloudfree)

Function to get an example image to debug or test some code.

Usage:
    var result = geet.load_image(collection, year, roi, cloudfree);   

Params:

optional (string) collection - the type of the collection that will be filtered: RAW, TOA, or SR.
optional (number) year - the year of the image that you want to get.
optional (list) roi - the latitude and longitude of a roi.
optional (bool) cloudFree - true for cloud mask processing and mean calculation.

Usage:
    var image = geet.load_image(); // Returns a TOA image   

or

    var image = geet.load_image('SR', 2015); // Returns a SR image   

load_id_s2

(id)

Function to filter the Sentinel-2 collection by Product ID obtained from the Copernicus Open Access Hub.

Usage:
    var result = geet.load_id_s2(id);   

Params:

(string) id - the ID of the Sentinel-2 image.

Usage:
    var s2_image = geet.load_id_s2('S2A_MSIL1C_20170512T093041_N0205_R136_T34TDN_20170512T093649');  

collection2image

(image, previous)

Function to merge all images of one image collection into a single band.

Usage:
    var result = geet.collection2image(image, previous);   

Params:

(ee.Image) image - The image of the image collection to add as a band.
(ee.Image) previous - The output image.

Usage:
    var geet = require('users/eduardolacerdageo/geet:geet'); 
    var merged_image = image_collection.iterate(geet.collection2image, ee.Image([]));   

anomaly

(image, reference_collection, band)

Calculates the Z-Score Anomaly of an image compared to a historical reference collection. Great for finding extreme events like droughts, heatwaves, or deforestation spikes.

Usage:
    var result = geet.anomaly(image, reference_collection, band);   

Params:

(ee.Image) image - The target image. (ee.ImageCollection) reference_collection - The historical baseline. (string) band - The name of the band to calculate the anomaly for (e.g. 'NDVI' or 'LST').

Usage:
  var anomaly_img = geet.anomaly(target_image, baseline_col, 'LST');

imad

(current, prev)

Iteratively Reweighted Multivariate Alteration Detection (iMAD) algorithm. Developed by Dr. Allan Nielsen and implemented in GEE by Dr. Mort Canty. This is a highly advanced statistical algorithm for detecting changes between two images and finding Pseudo-Invariant Features (PIFs) that didn't change.

Usage:
    var result = geet.imad(current, prev);   

Params:

(ee.Image) current - The target image. (ee.Dictionary) prev - The iteration dictionary containing state.



radcal

(current, prev)

Iterator function for orthogonal regression and interactive radiometric normalization. Called internally by radcalbatch.

Usage:
    var result = geet.radcal(current, prev);   

Params:

(ee.Image) current - The current band index. (ee.Dictionary) prev - The dictionary containing image and coeffs.


radcalbatch

(current, prev)

Performs Relative Radiometric Normalization using orthogonal regression on the invariant pixels discovered by the iMAD algorithm. Crucial for harmonizing a time series of images to a single reference image.

Usage:
    var result = geet.radcalbatch(current, prev);   

Params:

(ee.Image) current - The image to normalize. (ee.Dictionary) prev - The dictionary containing the reference image.


segmentation_snic

(image, size, compactness)

Function to segment an image using the SNIC (Simple Non-Iterative Clustering) algorithm.

Usage:
    var result = geet.segmentation_snic(image, size, compactness);   

Params:

(ee.Image) image - the input image. optional (number) size - The superpixel seed location spacing (default 10). optional (number) compactness - The compactness factor (default 1).

Usage:
  var snic = geet.segmentation_snic(img, 15, 1);

obia_classification

(image, trainingData, fieldName, options)

Function to perform a complete Object-Based Image Analysis (GEOBIA) classification. It automatically generates superpixels (SNIC), extracts spectral, spatial (geometry), and textural (GLCM) features per object, and classifies them using Machine Learning.

Usage:
    var result = geet.obia_classification(image, trainingData, fieldName, options);   

Params:

(ee.Image) image - The raw input image to segment and classify. (ee.FeatureCollection) trainingData - The training samples. (string) fieldName - The class column name. optional (Object) options - Dictionary of OBIA parameters: { snicSize: 15, snicCompactness: 1, classifier: 'rf', // 'rf', 'cart', 'svm' includeTexture: false, includeGeometry: true, scale: 30 }

Usage:
  var obia_results = geet.obia_classification(img, samples, 'class', {
      snicSize: 20,
      includeGeometry: true,
      includeTexture: true,
      classifier: 'rf'
  });
  
  // Extract the final classified map
  var classified = obia_results.select('classification');

filter_small_objects

(image, minArea, maxSize)

Eliminates small patches in a classified image (Minimum Mapping Unit filter) by replacing them with the most common neighboring class.

Usage:
    var result = geet.filter_small_objects(image, minArea, maxSize);   

Params:

(ee.Image) image - The classified image (single band). (number) minArea - The minimum area in square meters (e.g., 10000 for 1 hectare). optional (number) maxSize - The focal mode radius to fill gaps (default 50).

Usage:
  // Filter out any object smaller than 1 hectare (10,000 sq meters)
  var cleaned_map = geet.filter_small_objects(classified, 10000);

harmonic_trend

(timeseries, dependent_band, num_harmonics)

Generates a Fourier Harmonic Trend model for a time-series to extract Seasonality (Phase and Amplitude) and Linear Trend. It now supports multiple harmonics for modeling complex phenological cycles (e.g., double-cropping systems).

Usage:
    var result = geet.harmonic_trend(timeseries, dependent_band, num_harmonics);   

Params:

(ee.ImageCollection) timeseries - The input time-series collection. (string) dependent_band - The name of the band to model (e.g., 'NDVI'). optional (number) num_harmonics - The number of cycles per year to model (default: 1).

Usage:
  var trend = geet.harmonic_trend(landsat_ts, 'NDVI', 2);

zonal_statistics

(image, featureCollection, reducerType, scale)

Extracts zonal statistics from an image using polygons.

Usage:
    var result = geet.zonal_statistics(image, featureCollection, reducerType, scale);   

Params:

(ee.Image) image - the input image. (ee.FeatureCollection) featureCollection - the polygon regions. (string) reducerType - 'max', 'min', 'mean', 'median', 'mode', 'sd', 'variance', 'sum'. optional (number) scale - the scale in meters (default 30).

Usage:
  var stats = geet.zonal_statistics(ndvi_img, polygons, 'mean', 30);

harmonize_sensors

(image, source, target)

Harmonizes spectral values between Sentinel-2 and Landsat-8 using OLS regression coefficients.

Usage:
    var result = geet.harmonize_sensors(image, source, target);   

Params:

(ee.Image) image - the input image. (string) source - 'S2' or 'L8'. (string) target - 'S2' or 'L8'.

Usage:
  var harmonized = geet.harmonize_sensors(s2_img, 'S2', 'L8');

burn_severity

(pre_fire, post_fire, sensor)

Calculates the Normalized Burn Ratio (NBR), Delta NBR (dNBR), and Burn Severity Classes.

Usage:
    var result = geet.burn_severity(pre_fire, post_fire, sensor);   

Params:

(ee.Image) pre_fire - the pre-fire image. (ee.Image) post_fire - the post-fire image. optional (string) sensor - 'L8', 'L9', 'S2', etc. (default 'L8').

Usage:
  var severity = geet.burn_severity(img_before, img_after, 'L8');

Harmonized Landsat Sentinel-2 (HLS)


build_hls_composite

(roi, start_date, end_date, band)

Generates a Harmonized Landsat Sentinel-2 (HLS) median composite for the given region and time period. Uses Landsat 7, 8, 9 (Collection 2 Level 2) and Sentinel-2 (SR) images. Implements state-of-the-art NASA HLS algorithms including cloud/shadow masking, reflectance rescaling, BRDF normalization, spectral band adjustment (SBA), and spatial coregistration.

How it works: This is a monolithic "all-in-one" function that integrates data from four different satellite constellations (L7, L8, L9, S2). First, it queries all datasets and applies rigorous cloud/shadow masking (combining QA_PIXEL, Sentinel SCL, Sentinel Cloud Probability, and TDOM2). Then it applies BRDF (Bidirectional Reflectance Distribution Function) corrections using the c-factor method to normalize illumination angles across seasons and latitudes. Since Landsat and Sentinel have slightly different spectral response functions, it applies Spectral Band Adjustment (SBA) equations to match S2 and L7 radiometry to Landsat 8/9. Finally, it reprojects S2 to 30m, merges everything into a massive hyper-collection, and calculates the temporal median to yield a seamless, cloud-free, and radiometrically uniform composite.

Params:

(ee.Geometry) roi - The region of interest.
(string) start_date - Start date of the composite (e.g. '2019-10-01').
(string) end_date - End date of the composite (e.g. '2019-10-31').
optional (string) band - The specific band to process and return (e.g. 'NDVI', 'red'). Pass 'ALL' or leave empty to process all multispectral bands.

Usage:
    // Generates a full multi-band composite
    var hls_composite = geet.build_hls_composite(roi, '2022-01-01', '2022-12-31');   
    
    // Processes exclusively the NDVI to save computation time
    var hls_ndvi = geet.build_hls_composite(roi, '2022-01-01', '2022-12-31', 'NDVI');

rescale_landsat_c2

(image)

Applies scale factors for Landsat Collection 2 Level 2 SR to compute physical reflectance [0, 1].

Usage:
    var result = geet.rescale_landsat_c2(image);   

Params:

(ee.Image) image - The input Landsat Collection 2 image.

Usage:
    var rescaled_l8 = geet.rescale_landsat_c2(raw_l8_image);

rescale_sentinel2

(image)

Applies scale factors for Sentinel-2 SR to compute physical reflectance [0, 1].

Usage:
    var result = geet.rescale_sentinel2(image);   

Params:

(ee.Image) image - The input Sentinel-2 image.

Usage:
    var rescaled_s2 = geet.rescale_sentinel2(raw_s2_image);

apply_brdf_landsat

(image)

Normalizes Landsat image reflectance to Nadir BRDF-Adjusted Reflectance (NBAR) using the c-factor approach and Roy et al. (2016) parameters.

Usage:
    var result = geet.apply_brdf_landsat(image);   

Params:

(ee.Image) image - The input Landsat image. Must contain the date property.

Usage:
    var brdf_l8 = geet.apply_brdf_landsat(rescaled_l8);

apply_brdf_sentinel

(image)

Normalizes Sentinel-2 image reflectance to Nadir BRDF-Adjusted Reflectance (NBAR) using the c-factor approach and Roy et al. (2016) parameters.

Usage:
    var result = geet.apply_brdf_sentinel(image);   

Params:

(ee.Image) image - The input Sentinel-2 image. Must contain the date property.

Usage:
    var brdf_s2 = geet.apply_brdf_sentinel(rescaled_s2);

band_adjustment_landsat7

(landsat_image)

Applies Spectral Band Adjustment (SBA) to Landsat 7 ETM+ to align its spectral response with Landsat 8 OLI, based on Roy et al. (2016).

Usage:
    var result = geet.band_adjustment_landsat7(landsat_image);   

Params:

(ee.Image) landsat_image - The input Landsat 7 image.

Usage:
    var adjusted_l7 = geet.band_adjustment_landsat7(brdf_l7);

band_adjustment_sentinel2

(s2_image)

Applies Spectral Band Adjustment (SBA) to Sentinel-2 MSI to align its spectral response with Landsat 8 OLI, based on Chastain et al. (2019).

Usage:
    var result = geet.band_adjustment_sentinel2(s2_image);   

Params:

(ee.Image) s2_image - The input Sentinel-2 image.

Usage:
    var adjusted_s2 = geet.band_adjustment_sentinel2(brdf_s2);

Deprecated Functions (Legacy Support)

The following functions have been deprecated to streamline the GEET library. They are still exported as "stubs" that will throw an informative error if called, guiding legacy code users to the new, integrated functions.

  • build_annual_ls5_timeseries, build_annual_ls7_timeseries, build_annual_ls8_timeseries -> Replaced by: build_annual_landsat_timeseries(roi)
  • landsat5_timeseries, landsat7_timeseries, landsat8_timeseries -> Replaced by: landsat_timeseries(sensor, type)

If your legacy scripts use any of these old functions, please update them to use the new integrated functions, which offer better performance, Collection 2 compliance, and support for newer sensors like Landsat 9.