pixelArea#

classmethod geetools.ee_image.ImageAccessor.pixelArea(area_unit='m2', rename_to_units=False)#

Extend the :py:method:`ee.Image.pixelArea` method by setting the unit of the output.

Parameters:
  • area_unit (str) – the unit of the output area. can be one of “m2”, “ha”, “kha”, “km2” or “acres”.

  • rename_to_units (bool) – if True, the output image will be renamed to the given unit.

Returns:

the area ee.Image using the given unit.

Return type:

ee.Image

Examples

import ee, geetools
from geetools.utils import initialize_documentation

initialize_documentation()

hectares = ee.Image.geetools.pixelArea("ha").rename("ha")
acres = ee.Image.geetools.pixelArea("acres").rename("acres")
total = hectares.addBands(acres)

buffer = ee.Geometry.Point(0,0).buffer(100)
values = total.reduceRegion(ee.Reducer.mean(), buffer, 1)
values.getInfo()
{'acres': 0.0002454509480267026, 'ha': 9.933056235313415e-05}