geetools.algorithms#

Module holding misc algorithms.

Module Contents#

Classes#

Landsat

TODO add docstring.

Functions#

distanceToMask(image[, kernel, radius, unit, scale, ...])

Compute the distance to the mask in meters.

euclideanDistance(image1, image2[, bands, ...])

Compute the Euclidean distance between two images. The image's bands.

maskCover(image[, geometry, scale, property_name, ...])

Percentage of masked pixels (masked/total * 100) as an Image property.

pansharpenIhsFusion(image[, pan, rgb])

HSV-based Pan-Sharpening.

pansharpenKernel(image, pan[, rgb, kernel])

Compute the per-pixel means of the unsharpened bands.

sumDistance(image, collection[, bands, discard_zeros, ...])

Compute de sum of all distances between the given image and the.

class geetools.algorithms.Landsat[source]#

Bases: object

TODO add docstring.

static brdfCorrect(image, red='red', green='green', blue='blue', nir='nir', swir1='swir1', swir2='swir2')[source]#

Correct Landsat data for BRDF effects using a c-factor.

D.P. Roy, H.K. Zhang, J. Ju, J.L. Gomez-Dans, P.E. Lewis, C.B. Schaaf, Q. Sun, J. Li, H. Huang, V. Kovalskyy, A general method to normalize Landsat reflectance data to nadir BRDF adjusted reflectance, Remote Sensing of Environment, Volume 176, April 2016, Pages 255-271

Interpreted and coded here by Daniel Wiell and Erik Lindquist of the United Nations Food and Agriculture Organization

Transcipted to GEE Python API by Rodrigo E. Principe

If the band names of the passed image are ‘blue’, ‘green’, etc, those will be used, if not, relations must be indicated in params.

Return type:

ee.Image

static harmonization(image, blue='B2', green='B3', red='B4', nir='B5', swir='B6', swir2='B7', max_value=None)[source]#

Harmonization of Landsat 8 images to be consistent with.

Landsat 7 images.

Roy, D.P., Kovalskyy, V., Zhang, H.K., Vermote, E.F., Yan, L., Kumar, S.S, Egorov, A., 2016, Characterization of Landsat-7 to Landsat-8 reflective wavelength and normalized difference vegetation index continuity, Remote Sensing of Environment, 185, 57-70. (http://dx.doi.org/10.1016/j.rse.2015.12.024) Table 2 - reduced major axis (RMA) regression coefficients

Parameters:
  • image – A Landsat 8 Image

  • max_value – the maximum value for the optical bands. For float bands it is 1 (TOA), for int16 it is 10000 (SR) and for int8 it is 255 (RAW). It default to 1 (TOA)

Returns:

static rescaleSrToa(image, bands=None, thermal_bands=None)[source]#

Re-scale a TOA Landsat image to match the data type of SR Landsat.

image.

Parameters:
  • image (ee.Image) – a Landsat TOA image

  • bands (list) – bands to rescale by 10000. If None will use the bands for Landsat 8 (B[1-7]).

  • thermal_bands (list) – bands to rescale by 100. Defaults to [‘B10’, ‘B11’]

Return type:

ee.Image

static rescaleToaSr(image, bands=None, thermal_bands=None)[source]#

Re-scale a TOA Landsat image to match the data type of SR Landsat.

image.

Parameters:
  • image (ee.Image) – a Landsat TOA image

  • bands (list) – bands to rescale by 10000. If None will use the bands for Landsat 8 ([‘B1’,’B2’,’B3’,’B4’,’B5’,’B6’,’B7’]).

  • thermal_bands (list) – bands to rescale by 100. Defaults to [‘B10’, ‘B11’]

Return type:

ee.Image

static unmask_slc_off(image, optical_bands='B.+')[source]#

Unmask pixels that were affected by scl-off error in Landsat 7.

Expects a Landsat 7 image and it is meant to be used before any other masking, otherwise this could affect the previous mask.

The parameter optical_bands must be used if band were renamed. By default it is B.+ which means that optical bands are those starting with B: B1 (blue), B2 (green), B3 (red), B4 (nir), B5 (swir), B6 (thermal), B7 (swir2).

geetools.algorithms.distanceToMask(image, kernel=None, radius=1000, unit='meters', scale=None, geometry=None, band_name='distance_to_mask', normalize=False)[source]#

Compute the distance to the mask in meters.

Parameters:
  • image (ee.Image) – Image holding the mask

  • kernel (ee.Kernel) – Kernel to use for computing the distance. By default uses euclidean

  • radius (int) – radius for the kernel. Defaults to 1000

  • unit (str) – units for the kernel radius. Defaults to ‘meters’

  • scale (int) – scale for reprojection. If None, will reproject on the fly (according to EE lazy computing)

  • geometry (ee.Geometry or ee.Feature) – compute the distance only inside this geometry. If you want to compute the distance inside a clipped image, using this parameter will make the edges not be considered as a mask.

  • band_name (str) – name of the resulting band. Defaults to ‘distance_to_mask’

  • normalize (bool) – Normalize result (between 0 and 1)

Returns:

A one band image with the distance to the mask

Return type:

ee.Image

geetools.algorithms.euclideanDistance(image1, image2, bands=None, discard_zeros=False, name='distance')[source]#

Compute the Euclidean distance between two images. The image’s bands.

is the dimension of the arrays.

Parameters:
  • image1 (ee.Image) –

  • image2 (ee.Image) –

  • bands (list) – the bands that want to be computed

  • discard_zeros (bool) – pixel values equal to zero will not count in the distance computation

  • name (str) – the name of the resulting band

Returns:

a distance image

Return type:

ee.Image

geetools.algorithms.maskCover(image, geometry=None, scale=None, property_name='MASK_COVER', crs=None, crsTransform=None, bestEffort=False, maxPixels=10000000000000.0, tileScale=1)[source]#

Percentage of masked pixels (masked/total * 100) as an Image property.

Parameters:
  • image (ee.Image) – ee.Image holding the mask. If the image has more than one band, the first one will be used

  • geometry (ee.Geometry or ee.Feature) – the value will be computed inside this geometry. If None, will use image boundaries. If unbounded the result will be 0

  • scale (int) – the scale of the mask

  • property_name (str) – the name of the resulting property

Returns:

The same parsed image with a new property holding the mask cover percentage

Return type:

ee.Image

geetools.algorithms.pansharpenIhsFusion(image, pan=None, rgb=None)[source]#

HSV-based Pan-Sharpening.

source: https://gis.stackexchange.com/questions/296615/pansharpen-landsat-mosaic-in-google-earth-engine.

Parameters:

image (ee.Image) –

the name of the panchromatic band :type pan: str :param rgb: the red green blue bands :type rgb: tuple or list :rtype: ee.Image

geetools.algorithms.pansharpenKernel(image, pan, rgb=None, kernel=None)[source]#

Compute the per-pixel means of the unsharpened bands.

source: https://gis.stackexchange.com/questions/296615/pansharpen-landsat-mosaic-in-google-earth-engine.

Parameters:
  • pan (str) – the name of the panchromatic band

  • rgb (tuple or list) – the red green blue bands

  • kernel (ee.Kernel) – the kernel to reduce neighbors

Return type:

ee.Image

geetools.algorithms.sumDistance(image, collection, bands=None, discard_zeros=False, name='sumdist')[source]#

Compute de sum of all distances between the given image and the.

collection passed.

Parameters:
  • image

  • collection

Returns: