Google Earth Engine(gee)中的Date和DateRange
程序员文章站
2022-05-26 19:13:44
...
一、Date
基本用法
print(ee.Date('1970-01-01'))
print(ee.Date(24*60*60*1000))
print(ee.Date.fromYMD(2015,2,12))//,表示2月需用2,不能用02
print(ee.Date.parse( 'yyyy-MM-dd-HH-mm-ss','2015-1-12-15-4-12' ))
时间单位增加
var Date_0 = ee.Date( '1970-01-01' );
var Date_1 = Date_0.advance( 1, 'year' );
var Date_2 = Date_0.advance( 1, 'month' );
var Date_3 = Date_0.advance( 1, 'week' );
var Date_4 = Date_0.advance( 1, 'day' );
var Date_5 = Date_0.advance( 1, 'hour' );
var Date_6 = Date_0.advance( 1, 'minute' );
var Date_7 = Date_0.advance( 1, 'second' );
print("Date_0",Date_0)
print(Date_1, Date_2,Date_3,Date_4,Date_5,Date_6,Date_7);
更改时间格式
var date = ee.Date.fromYMD( 2015, 1, 12 );
var date_format = date.format('MM-dd-yyyy' );
print( date, date_format );
时间求毫秒值
print(ee.Date.parse( 'yyyy-MM-dd-HH-mm-ss','1970-01-01-00-00-01'));
print(ee.Date.parse( 'yyyy-MM-dd-HH-mm-ss','1970-01-01-00-00-01').millis());
print(ee.Date.parse( 'yyyy-MM-dd-HH-mm-ss','1970-01-01-00-00-02').millis());
提取时间范围
print(ee.Date( '2000-05-20' ));
print(ee.Date( '2000-05-20' ).getRange('year'));
print(ee.Date( '2000-05-20' ).getRange('month'));
print(ee.Date( '2000-05-20' ).getRange('day'));
提取时间单位值
print(ee.Date( '2000-05-20' ));
print(ee.Date( '2000-05-20' ).get('year'));
print(ee.Date( '2000-05-20' ).get('month'));
print(ee.Date( '2000-05-20' ).get('day'));
时间单位的比例
print(ee.Date( '2000-05-28' ));
print(ee.Date( '2000-05-28' ).getFraction('year'));
print((31+28+31+30+28)/366)
逝去时间的求取
print(ee.Date( '2000-05-20' ).getRelative( 'day','month' ))//这个月过了多少天
print(ee.Date( '2000-05-20' ).getRelative( 'day','year' ))//今年过了多少天
print(ee.Date( '2000-05-20' ).getRelative( 'month','year' ))//今年过了几个月
print(ee.Date( '2000-05-20' ).getRelative( 'hour','year' ))//今年过了几个小时
时间单位的比值求取
print( ee.Date.unitRatio( 'day', 'year' ),1/365 );
print( ee.Date.unitRatio( 'month', 'year' ),1/12 );
print( ee.Date.unitRatio( 'day', 'month' ),1/31 );
print( ee.Date.unitRatio( 'hour', 'day' ),1/24 );
print( ee.Date.unitRatio( 'minute', 'hour' ),1/60 );
print( ee.Date.unitRatio( 'second', 'minute' ),1/60 );
时间差值的求取
print(ee.Date( '2005-01-01').difference(ee.Date( '2000-01-01'),"year"))
print(ee.Date( '2005-01-01').difference(ee.Date( '2000-01-01'),"month"))
print(ee.Date( '2005-01-01').difference(ee.Date( '2000-01-01'),"day"))
二、DateRange
基本用法
无限时间段
时间段取交集
var date1=ee.DateRange('2000-01-01','2015-1-1')
var date2=ee.DateRange('2005-01-01','2020-1-1')
print(date1,date2,date2.intersection(date1))
时间段取起、止时间
print(ee.DateRange('2000-01-01','2015-1-1'))
print(ee.DateRange('2000-01-01','2015-1-1').start())
print(ee.DateRange('2000-01-01','2015-1-1').end())
时间段的内容检测
print(ee.DateRange('2000-01-01','2015-1-1'))
print(ee.DateRange('2000-01-01','2015-1-1').isEmpty())
print(ee.DateRange('2000-01-01','2015-1-1').isUnbounded())
print(ee.DateRange('2015-1-1','2000-01-01').isEmpty())
print(ee.DateRange('2015-1-1','2000-01-01').isUnbounded())
print(ee.DateRange('2000-01-01'))
print(ee.DateRange('2000-01-01').isEmpty())
print(ee.DateRange('2000-01-01').isUnbounded())
上一篇: Windows查看端口占用
下一篇: git提交代码流程
推荐阅读
-
google earth engine(GEE)如何在看某一点的经纬度、波段信息
-
Google Earth Engine(GEE)对指定地点Sentinel-2 Level1C数据进行NDVI指数的计算
-
Google Earth Engine(gee)中的List
-
Google Earth Engine(gee)中的Dictionary
-
Google Earth Engine(gee)中的Date和DateRange
-
Google Earth Engine(gee)中的String和Number
-
Google Earth Engine(GEE)对指定地点Sentinel-2 Level1C数据的读取及云量处理
-
Google Earth Engine(gee)中的Feature
-
google earth engine(GEE)如何在看某一点的经纬度、波段信息