ee.Date.unitRatio

  • The unitRatio function returns the ratio of the length of one time unit to another.

  • Valid time units for the function are year, month, week, day, hour, minute, and second.

  • The function takes two string arguments, numerator and denominator , representing the units to compare.

  • The output of the function is a floating-point number representing the calculated ratio.

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'.
Usage Returns
ee.Date.unitRatio(numerator, denominator) Float
Argument Type Details
numerator
String
denominator
String

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' 
 )) 
Create a Mobile Website
View Site in Mobile | Classic
Share by: