geetools.Image#

Toolbox for the ee.Image class.

Package Contents#

Classes#

ImageAccessor

Toolbox for the ee.Image class.

class geetools.Image.ImageAccessor(obj)[source]#

Toolbox for the ee.Image class.

Initialize the Image class.

Parameters:

obj (ee.Image) –

addDate()[source]#

Add a band with the date of the image in the provided format.

The date is stored as a Timestamp in millisecond in a band “date”.

Returns:

The image with the date band added.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM')
image = image.geetools.addDate()
date = image.select('date')
buffer = ee.Geometry.Point([12.4534, 41.9033]).buffer(100)
value = date.reduceRegion(ee.Reducer.first(), buffer, 10).get("date")
ee.Date(value).format('YYYY-MM-dd').getInfo()
addPrefix(prefix, bands=[])[source]#

Add a prefix to the image selected band.

Add a prefix to the selected band. If no band is specified, the prefix is added to all bands.

Parameters:
  • prefix (geetools.types.ee_str) – The prefix to add to the band.

  • bands (geetools.types.ee_list) – The bands to add the prefix to. If None, all bands are selected.

Returns:

The image with the prefix added to the selected bands.

Examples

import ee, geetools

ee.Initialize()

image = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM')
image = image.geetools.addPrefix('prefix_')
print(image.bandNames().getInfo())
addSuffix(suffix, bands=[])[source]#

Add a suffix to the image selected band.

Add a suffix to the selected band. If no band is specified, the suffix is added to all bands.

Parameters:
  • suffix (geetools.types.ee_str) – The suffix to add to the band.

  • bands (geetools.types.ee_list) – The bands to add the suffix to. If None, all bands are selected.

Returns:

The image with the suffix added to the selected bands.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM')
image = image.geetools.addSuffix('_suffix')
print(image.bandNames().getInfo())
bufferMask(radius=1.5, kernelType='square', units='pixels')[source]#

Make a buffer around every masked pixel of the Image.

The buffer will be made using the specified radius, kernelType and units and will mask surrounfing pixels.

Parameters:
  • radius (geetools.types.ee_int) – The radius of the buffer.

  • kernelType (geetools.types.ee_str) – The kernel type of the buffer. One of: square, circle, diamond, octagon, plus, square.

  • units (geetools.types.ee_str) – The units of the radius. One of: pixels, meters.

Returns:

The image with the buffer mask applied.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

src = 'COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM'
image = ee.Image(src)
image = image.geetools.bufferMask(1.5, 'square', 'pixels')
print(image.bandNames().getInfo())
clipOnCollection(fc, keepProperties=1)[source]#

Clip an image to a FeatureCollection.

The image will be clipped to every single features of the featureCollection as one independent image.

Parameters:
  • fc (ee.FeatureCollection) – The featureCollection to clip to.

  • keepProperties (geetools.types.ee_int) – If True, the properties of the featureCollection will be added to the clipped image.

Returns:

The clipped imageCollection.

Return type:

ee.ImageCollection

Examples

import ee, geetools

ee.Initialize()

src = 'COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM'
image = ee.Image(src)
fc = ee.FeatureCollection('FAO/GAUL/2015/level0')
clipped = image.geetools.clipOnCollection(fc)
print(clipped.size().getInfo())
doyToDate(year, dateFormat='yyyyMMdd', band='')[source]#

Convert the DOY band to a date band.

This method only work with date formats that can be converted to numbers as earthengine images don’t accept string bands.

Parameters:
  • year – The year to use for the date

  • dateFormat (geetools.types.ee_str) – The date format to use for the date band

  • band (geetools.types.ee_str) – The band to use as DOY band. If empty, the first one is selected.

Returns:

The original image with the DOY band converted to a date band.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image = ee.Image.random().multiply(365).toInt()
vatican = ee.Geometry.Point([12.4534, 41.9033]).buffer(1)

image = image.geetools.doyToDate(2023)
print(image.reduceRegion(ee.Reducer.min(), vatican, 1).getInfo())
format(string, dateFormat='yyyy-MM-dd')[source]#

Create a string from using the given pattern and using the image properties.

The system_date property is special cased to fit the dateFormat parameter.

Parameters:
  • string (geetools.types.ee_str) – The pattern to use for the string

  • dateFormat (geetools.types.ee_str) – The date format to use for the system_date property

Returns:

The string corresponding to the image

Return type:

ee.String

Examples

import ee, geetools

ee.Initialize()

image = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM')
string = image.geetools.format('this is the image date: {system_date}')
print(string.getInfo())
classmethod full(values=[0], names=['constant'])[source]#

Create an image with the given values and names.

Parameters:
  • values (geetools.types.ee_list) – The values to initialize the image with. If one value is given, it will be used for all bands.

  • names (geetools.types.ee_list) – The names of the bands. By default it uses the earthen engine default value, “constant”.

Returns:

An image with the given values and names.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image = ee.Image.geetools.full([1, 2, 3], ['a', 'b', 'c'])
print(image.bandNames().getInfo())
fullLike(fillValue, copyProperties=0, keepMask=0)[source]#

Create an image with the same band names, projection and scale as the original image.

The projection is computed on the first band, make sure all bands have the same. The procduced image can also copy the properties of the original image and keep the mask.

Parameters:
  • fillValue (geetools.types.ee_number) – The value to fill the image with.

  • copyProperties (geetools.types.ee_int) – If True, the properties of the original image will be copied to the new one.

  • keepMask (geetools.types.ee_int) – If True, the mask of the original image will be copied to the new one.

Returns:

An image with the same band names, projection and scale as the original image.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM')
image = image.geetools.fullLike(0)
print(image.bandNames().getInfo())
gauss(band='')[source]#

Apply a gaussian filter to the image.

We apply the following function to the image: “exp(((val-mean)**2)/(-2*(std**2)))” where val is the value of the pixel, mean is the mean of the image, std is the standard deviation of the image.

See the Gaussian filter Wikipedia page for more information.

Parameters:

band (geetools.types.ee_str) – The band to apply the gaussian filter to. If empty, the first one is selected.

Returns:

The image with the gaussian filter applied.An single band image with the gaussian filter applied.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image = ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED").first()
image = image.geetools.gauss()
print(image.bandNames().getInfo())
getCitation()[source]#

Gets the citation of the image, if available.

Returns:

Citation of the ee.Image dataset.

Return type:

str

Examples

import ee
import geetools

ee.Initialize()

ee.ImageCollection('NASA/GPM_L3/IMERG_V06').first().getCitation()
getDOI()[source]#

Gets the DOI of the image, if available.

Returns:

DOI of the ee.Image dataset.

Return type:

str

Examples

import ee
import geetools

ee.Initialize()

ee.ImageCollection('NASA/GPM_L3/IMERG_V06').first().getDOI()
getOffsetParams()[source]#

Gets the offset parameters for each band of the image.

Returns:

Dictionary with the offset parameters for each band.

Return type:

dict

Examples


import ee import geetools

ee.Initialize()

ee.ImageCollection(‘MODIS/006/MOD11A2’).first().getOffsetParams()

getSTAC()[source]#

Gets the STAC of the image.

Returns:

STAC of the image.

Return type:

dict

Examples


import ee import geetools

ee.Initialize()

ee.ImageCollection(‘COPERNICUS/S2_SR’).first().getSTAC()

getScaleParams()[source]#

Gets the scale parameters for each band of the image.

Returns:

Dictionary with the scale parameters for each band.

Return type:

dict

Examples

import ee
import geetools

ee.Initialize()

ee.ImageCollection('MODIS/006/MOD11A2').first().geetools.getScaleParams()
getValues(point, scale=0)[source]#

Get the value of the image at the given point using specified geometry.

The result is presented as a dictionary where the keys are the bands name and the value the mean value of the band at the given point.

Parameters:
  • point (ee.Geometry.Point) – The geometry to get the value from.

  • scale (geetools.types.ee_int) –

Returns:

A dictionary with the band names and the value at the given point.

Return type:

ee.Dictionary

Examples

import ee, geetools

ee.Initialize()

image = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM')
point = ee.Geometry.Point([11.0, 45.0])
value = image.geetools.getValues(point, 10)
print(value.getInfo())
index_list()[source]#

Return the list of indices implemented in this module.

Returns:

List of indices implemented in this module

Return type:

dict

Examples

import ee, geetools

ind = ee.Image.geetools.indices()["BAIS2"]
print(ind["long_name"])
print(ind["formula"])
print(ind["reference"])
interpolateBands(src, to)[source]#

Interpolate bands from the “src” value range to the “to” value range.

The Interpolation is performed linearly using the “extrapolate” option of the “interpolate” method.

Parameters:
  • src (geetools.types.ee_list) – The source value range

  • to (geetools.types.ee_list) – The target value range

Returns:

The image with the interpolated bands

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

vatican = ee.Geometry.Point([12.4534, 41.9033]).buffer(1)
image = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED').filterBounds(vatican).first()
image = image.select(["B4", "B3", "B2"]).geetools.interpolateBands([0, 3000], [0, 30])
values = image.reduceRegion(ee.Reducer.mean(), vatican, 1)
print(values.getInfo())
isletMask(offset)[source]#

Compute the islet mask from an image.

An islet is a set of non-masked pixels connected together by their edges of very small surface. The user define the offset of the island size and we compute the max number of pixels to improve computation speed. The inpt Image needs to be a single band binary image.

Parameters:

offset (geetools.types.ee_number) – The limit of the islet size in square metters

Returns:

The island mask

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image = ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED").first()
mask = image.select('SCL').eq(4)
mask = mask.geetools.islandMask(100)
print(mask.bandNames().getInfo())
maskClouds(method='cloud_prob', prob=60, maskCirrus=True, maskShadows=True, scaledImage=False, dark=0.15, cloudDist=1000, buffer=250, cdi=None)[source]#

Masks clouds and shadows in an image (valid just for Surface Reflectance products).

Parameters:
  • self – Image to mask.

  • method (str) –

    Method used to mask clouds. This parameter is ignored for Landsat products. Available options:

    • ’cloud_prob’ : Use cloud probability.

    • ’qa’ : Use Quality Assessment band.

  • prob (int) – Cloud probability threshold. Valid just for method = ‘cloud_prob’. This parameter is ignored for Landsat products.

  • maskCirrus (bool) – Whether to mask cirrus clouds. Default to True. Valid just for method = ‘qa’. This parameter is ignored for Landsat products.

  • maskShadows (bool) – Whether to mask cloud shadows. Default to True This parameter is ignored for Landsat products.

  • scaledImage (bool) – Whether the pixel values are scaled to the range [0,1] (reflectance values). This parameter is ignored for Landsat products.

  • dark (float) – NIR threshold. NIR values below this threshold are potential cloud shadows. This parameter is ignored for Landsat products.

  • cloudDist (int) – Maximum distance in meters (m) to look for cloud shadows from cloud edges. This parameter is ignored for Landsat products.

  • buffer (int) – Distance in meters (m) to dilate cloud and cloud shadows objects. This parameter is ignored for Landsat products.

  • cdi (Optional[int]) – Cloud Displacement Index threshold. Values below this threshold are considered potential clouds. A cdi = None means that the index is not used. This parameter is ignored for Landsat products.

Returns:

Cloud-shadow masked image.

Notes

This method may mask water as well as clouds for the Sentinel-3 Radiance product.

Examples

import ee, geetools

ee.Initialize()
S2 = (
    ee.ImageCollection('COPERNICUS/S2_SR')
    .first()
    .maskClouds(prob = 75,buffer = 300,cdi = -0.5))
matchHistogram(target, bands, geometry=None, maxBuckets=256)[source]#

Adjust the image’s histogram to match a target image.

Parameters: target: Image to match. bands: A dictionary of band names to match, with source bands as keys and target bands as values. geometry: The region to match histograms in that overlaps both images. If none is provided, the geometry of the source image will be used. maxBuckets: The maximum number of buckets to use when building histograms. Will be rounded to the nearest power of 2.

Returns:

The adjusted image containing the matched source bands.

Parameters:
  • target (ee.Image) –

  • bands (dict) –

  • geometry (Optional[ee.Geometry]) –

  • maxBuckets (int) –

Return type:

ee.Image

Examples

import ee
import geetools

ee.Initialize()

source = ee.Image("LANDSAT/LC08/C01/T1_TOA/LC08_047027_20160819")
target = ee.Image("LANDSAT/LE07/C01/T1_TOA/LE07_046027_20150701")
bands = {
    "B4": "B3",
    "B3": "B2",
    "B2": "B1"
}
matched = source.matchHistogram(target, bands)
merge(images)[source]#

Merge images into a single image.

Parameters:

images (geetools.types.ee_list) – The images to merge.

Returns:

The merged image.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image1 = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM')
image2 = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQL')
image3 = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM')
image = image1.geetools.merge([image2, image3])
print(image.bandNames().getInfo())
minScale()[source]#

Return the minimum scale of the image.

It will be looking at all bands available so Select specific values before using this method.

Returns:

The minimum scale of the image.

Return type:

ee.Number

Examples

import ee, geetools

ee.Initialize()

image = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM')
image.geetools.minScale().getInfo()
negativeClip(geometry)[source]#

The opposite of the clip method.

The inside of the geometry will be masked from the image.

Parameters:

geometry (geetools.types.ee_geomlike) – The geometry to mask from the image.

Returns:

The image with the geometry masked.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

src, bands = "COPERNICUS/S2_SR_HARMONIZED", ["B1", "B2", "B3"]
vatican = ee.Geometry.Point([12.4534, 41.9033]).buffer(1)

image = ee.ImageCollection(src).filterBounds(vatican).first().select(bands)
image = image.geetools.negativeClip(vatican)
print(image.reduceRegion(ee.Reducer.mean(), vatican, 1).getInfo())
panSharpen(method='SFIM', qa='', **kwargs)[source]#

Apply panchromatic sharpening to the Image.

Optionally, run quality assessments between the original and sharpened Image to measure spectral distortion and set results as properties of the sharpened Image.

Parameters: method: The sharpening algorithm to apply. Current options are “SFIM” (Smoothing Filter-based Intensity Modulation), “HPFA” (High Pass Filter Addition), “PCS” (Principal Component Substitution), and “SM” (simple mean). Different sharpening methods will produce different quality sharpening results in different scenarios. qa: One or more optional quality assessment names to apply after sharpening. Results will be stored as image properties with the pattern geetools:metric, e.g. geetools:RMSE. **kwargs: Keyword arguments passed to ee.Image.reduceRegion() such as “geometry”, “maxPixels”, “bestEffort”, etc. These arguments are only used for PCS sharpening and quality assessments.

Returns:

The Image with all sharpenable bands sharpened to the panchromatic resolution and quality assessments run and set as properties.

Parameters:
  • method (str) –

  • qa (str) –

Return type:

ee.Image

Examples

import ee
import geetools

ee.Initialize()

source = ee.Image("LANDSAT/LC08/C01/T1_TOA/LC08_047027_20160819")
sharp = source.panSharpen(method="HPFA", qa=["MSE", "RMSE"], maxPixels=1e13)
preprocess(**kwargs)[source]#

Pre-processes the image: masks clouds and shadows, and scales and offsets the image.

Parameters:

**kwargs – Keywords arguments for maskClouds method.

Returns:

Pre-processed image.

Return type:

ee.Image

Examples


import ee import geetools

ee.Initialize() S2 = ee.ImageCollection(‘COPERNICUS/S2_SR’).first().preprocess()

reduceBands(reducer, bands=[], name='')[source]#

Reduce the image using the selected reducer and adding the result as a band using the selected name.

Parameters:
  • bands (geetools.types.ee_list) – The bands to reduce

  • reducer (str) – The reducer to use

  • name (geetools.types.ee_str) – The name of the new band

Returns:

The image with the new reduced band added

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM')
image = image.geetools.reduceBands("mean", ['B1', 'B2'])
print(image.bandNames().getInfo())
remove(bands)[source]#

Remove bands from the image.

Parameters:

bands (geetools.types.ee_list) – The bands to remove.

Returns:

The image without the specified bands.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

src = 'COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM'
image = ee.Image(src).select(['B1', 'B2', 'B3'])
image = image.geetools.remove(['B1', 'B2'])
print(image.bandNames().getInfo())
removeProperties(properties)[source]#

Remove a list of properties from an image.

Parameters:

properties (geetools.types.ee_list) – List of properties to remove from the image.

Returns:

Image with the specified properties removed.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image = ee.Image('COPERNICUS/S2_SR/20190828T151811_20190828T151809_T18GYT')
image = image.removeProperties(["system:time_start"])
removeZeros()[source]#

Return an image array with non-zero values extracted from each band.

This function processes a multi-band image array, where each band represents different data. It removes zero values from each band independently and then combines the non-zero values from all bands into a single image. The resulting image may have inconsistent array lengths for each pixel, as the number of zero values removed can vary across bands.

Returns:

The image with the zero values removed from each band.

Return type:

ee.Image

Example

import ee, geetools

ee.Initialize()

vatican = ee.Geometry.Point([12.4534, 41.9033]).buffer(1)
image = ee.Image([0, 1, 2]).toArray()
image = image.geetools.removeZeros()
values = image.reduceRegion(ee.Reducer.first(), vatican, 1)
print(values.getInfo())
rename(names)[source]#

Rename the bands of the image based on a dictionary.

It’s the same function as the one from GEE but it takes a dictionary as input. Keys are the old names and values are the new names.

Parameters:

names (geetools.types.ee_dict) – The new names of the bands.

Returns:

The image with the new band names.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

src = 'COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM'
image = ee.Image(src).select(['B1', 'B2', 'B3'])
image = image.geetools.rename({'B1': 'Aerosol', 'B2': 'Blue'})
print(image.bandNames().getInfo())
repeat(band, repeats)[source]#

Repeat a band of the image.

Parameters:
  • band – The band to repeat

  • repeats (geetools.types.ee_int) – The number of times to repeat the band

Returns:

The image with the band repeated

Return type:

ee.image

Examples

import ee, geetools

ee.Initialize()

image = ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED").first()
image = image.geetools.repeat('B1', 2)
print(image.bandNames().getInfo())
scaleAndOffset()[source]#

Scales bands on an image according to their scale and offset parameters.

Returns:

Scaled image.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

S2 = ee.ImageCollection('COPERNICUS/S2_SR').first().scaleAndOffset()
spectralIndices(index='NDVI', G=2.5, C1=6.0, C2=7.5, L=1.0, cexp=1.16, nexp=2.0, alpha=0.1, slope=1.0, intercept=0.0, gamma=1.0, omega=2.0, beta=0.05, k=0.0, fdelta=0.581, kernel='RBF', sigma='0.5 * (a + b)', p=2.0, c=1.0, lambdaN=858.5, lambdaR=645.0, lambdaG=555.0, online=False)[source]#

Computes one or more spectral indices (indices are added as bands) for an image from the Awesome List of Spectral Indices.

Parameters:
  • self – Image to compute indices on. Must be scaled to [0,1].

  • index (str) –

    Index or list of indices to compute, default = ‘NDVI’ Available options:

    • ’vegetation’ : Compute all vegetation indices.

    • ’burn’ : Compute all burn indices.

    • ’water’ : Compute all water indices.

    • ’snow’ : Compute all snow indices.

    • ’urban’ : Compute all urban (built-up) indices.

    • ’kernel’ : Compute all kernel indices.

    • ’all’ : Compute all indices listed below.

    • Awesome Spectral Indices for GEE: Check the complete list of indices here.

  • G (geetools.types.number) – Gain factor. Used just for index = ‘EVI’, default = 2.5

  • C1 (geetools.types.number) – Coefficient 1 for the aerosol resistance term. Used just for index = ‘EVI’, default = 6.0

  • C2 (geetools.types.number) – Coefficient 2 for the aerosol resistance term. Used just for index = ‘EVI’, default = 7.5

  • L (geetools.types.number) – Canopy background adjustment. Used just for index = [‘EVI’,’SAVI’], default = 1.0

  • cexp (geetools.types.number) – Exponent used for OCVI, default = 1.16

  • nexp (geetools.types.number) – Exponent used for GDVI, default = 2.0

  • alpha (geetools.types.number) – Weighting coefficient used for WDRVI, default = 0.1

  • slope (geetools.types.number) – Soil line slope, default = 1.0

  • intercept (geetools.types.number) – Soil line intercept, default = 0.0

  • gamma (geetools.types.number) – Weighting coefficient used for ARVI, default = 1.0

  • omega (geetools.types.number) – Weighting coefficient used for MBWI, default = 2.0

  • beta (geetools.types.number) – Calibration parameter used for NDSIns, default = 0.05

  • k (geetools.types.number) – Slope parameter by soil used for NIRvH2, default = 0.0

  • fdelta (geetools.types.number) – Adjustment factor used for SEVI, default = 0.581

  • kernel (str) –

    Kernel used for kernel indices, default = ‘RBF’ Available options:

    • ’linear’ : Linear Kernel.

    • ’RBF’ : Radial Basis Function (RBF) Kernel.

    • ’poly’ : Polynomial Kernel.

  • sigma (str) – Length-scale parameter. Used for kernel = ‘RBF’, default = ‘0.5 * (a + b)’. If str, this must be an expression including ‘a’ and ‘b’. If numeric, this must be positive.

  • p (geetools.types.number) – Kernel degree. Used for kernel = ‘poly’, default = 2.0

  • c (geetools.types.number) – Free parameter that trades off the influence of higher-order versus lower-order terms in the polynomial kernel. Used for kernel = ‘poly’, default = 1.0. This must be greater than or equal to 0.

  • lambdaN (geetools.types.number) – NIR wavelength used for NIRvH2 and NDGI, default = 858.5

  • lambdaR (geetools.types.number) – Red wavelength used for NIRvH2 and NDGI, default = 645.0

  • lambdaG (geetools.types.number) – Green wavelength used for NDGI, default = 555.0

  • drop – Whether to drop all bands except the new spectral indices, default = False

  • online (geetools.types.number) –

Returns:

Image with the computed spectral index, or indices, as new bands.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()
image = ee.Image('COPERNICUS/S2_SR/20190828T151811_20190828T151809_T18GYT')
image = image.specralIndices(["NDVI", "NDFI"])
tasseledCap()[source]#

Calculates tasseled cap brightness, wetness, and greenness components.

Tasseled cap transformations are applied using coefficients published for these supported platforms:

  • Sentinel-2 MSI Level 1C

  • Landsat 9 OLI-2 SR

  • Landsat 9 OLI-2 TOA

  • Landsat 8 OLI SR

  • Landsat 8 OLI TOA

  • Landsat 7 ETM+ TOA

  • Landsat 5 TM Raw DN

  • Landsat 4 TM Raw DN

  • Landsat 4 TM Surface Reflectance

  • MODIS NBAR

Parameters:

self – ee.Image to calculate tasseled cap components for. Must belong to a supported platform.

Returns:

Image with the tasseled cap components as new bands.

Return type:

ee.Image

Examples

import ee, geetools

ee.Initialize()

image = ee.Image('COPERNICUS/S2_SR/20190828T151811_20190828T151809_T18GYT')
img = img.tasseledCap()
toGrid(size=1, band='', geometry=None)[source]#

Convert an image to a grid of polygons.

Based on the size given by the user, the tool will build a grid of size*pixelSize x size * pixelSize cells. Each cell will be a polygon. Note that for images that have multiple scale depending on the band, we will use the first one or the one stated in the parameters.

Parameters:
  • size (geetools.types.ee_int) – The size of the grid. It will be size * pixelSize x size * pixelSize cells.

  • band (geetools.types.ee_str) – The band to burn into the grid.

  • geometry (Optional[ee.Geometry]) – The geometry to use as reference for the grid. If None, the image footprint will be used.

Returns:

The grid as a FeatureCollection.

Return type:

ee.FeatureCollection

Note

The method has a known bug when the projection of the image is different than 3857. As we use a buffer, the grid cells can slightly overlap. Feel free to open a Issue and contribute if you feel it needs improvements.

Examples

import ee, geetools

ee.Initialize()

src = 'COPERNICUS/S2_SR_HARMONIZED/20200101T100319_20200101T100321_T32TQM'
image = ee.Image(src)
buffer = ee.Geometry.Point([12.4534, 41.9033]).buffer(100)
grid = image.geetools.toGrid(1, 'B2', buffer)
print(grid.getInfo())