ee.Date.unitRatio

  • ee.Date.unitRatio() calculates the length ratio between two time units, such as days and minutes.

  • Valid time units for this function include 'year', 'month', 'week', 'day', 'hour', 'minute', and 'second'.

  • The function takes two string arguments: the numerator unit and the denominator unit, and returns a float representing the ratio.

  • Example: ee.Date.unitRatio('day', 'minute') would return 1440, indicating there are 1440 minutes in a day.

Returns the ratio of the length of one unit to the length of another, e.g., unitRatio('day', 'minute') returns 1440. Valid units are 'year', 'month', 'week', 'day', 'hour', 'minute', and 'second'.

UsageReturns
ee.Date.unitRatio(numerator, denominator)Float
ArgumentTypeDetails
numeratorString
denominatorString

Examples

Code Editor (JavaScript)

print('Minutes in a day', ee.Date.unitRatio('day', 'minute'));
print('Seconds in a year', ee.Date.unitRatio('year', 'second'));
print('Years in a month', ee.Date.unitRatio('month', 'year'));
print('Hours in a week', ee.Date.unitRatio('week', 'hour'));

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

import ee
import geemap.core as geemap

Colab (Python)

display('Minutes in a day:', ee.Date.unitRatio('day', 'minute'))
display('Seconds in a year:', ee.Date.unitRatio('year', 'second'))
display('Years in a month:', ee.Date.unitRatio('month', 'year'))
display('Hours in a week:', ee.Date.unitRatio('week', 'hour'))