GEE(Google Earth Engine)计算全球100年的夜间灯光数据!

简介: GEE(Google Earth Engine)计算全球100年的夜间灯光数据!



在开始写代码之前,我们要讲一下几个基础的GEE中内置的一些用法:


ee.Date(date, tz)

Constructs a new Date object.构造一个新的时间对象


Arguments:

date (ComputedObject|Date|Number|String):计算的数据类型包括了哪些

The date to convert, one of: a number (number of milliseconds since the epoch), an ISO Date string, a JavaScript Date or a ComputedObject.

要转换的日期,分别可以是以下之一:数字(自纪元以来的毫秒数)、ISO 日期字符串、JavaScript 日期或 ComputedObject。

tz (String, optional):时区的选择,一般情况下可以忽略。

An optional timezone only to be used with a string date.

仅与字符串日期一起使用的可选时区


Returns: Date

difference(start, unit)

Returns the difference between two Dates in the specified units; the result is floating-point and based on the average length of the unit.

以指定单位返回两个日期之间的差值;结果是浮点数并基于单位的平均长度。一般情况下输入你的开始时间和你要精确到的单位。


Arguments:

this:date (Date)

start (Date)

unit (String):

One of 'year', 'month' 'week', 'day', 'hour', 'minute', or 'second'.


Returns: Float

ee.Reducer.linearFit()

Returns a Reducer that computes the slope and offset for a (weighted) linear regression of 2 inputs. The inputs are expected to be x data followed by y data..

这个就相当于计算斜率,根据你输入的x值来改变Y的变化,


No arguments.

Returns: Reducer

好了接下来进行代码分析:

//先进行时间函数的确立,并添加波段,方便一会进行map遍历分析
function createTimeBand(img) {
  var year = img.date().difference(ee.Date('1990-01-01'), 'year');
  return ee.Image(year).float().addBands(img);
}
// Fit a linear trend to the nighttime lights collection.
var collection = ee.ImageCollection('NOAA/DMSP-OLS/CALIBRATED_LIGHTS_V4')
    .select('avg_vis')
    .map(createTimeBand);
//通过ee.Reducer.linearFit()来计算其变化趋势
var fit = collection.reduce(ee.Reducer.linearFit());
//选择第一张影像进行分析和展示
// Display a single image
Map.addLayer(ee.Image(collection.select('avg_vis').first()),
         {min: 0, max: 63},
         'stable lights first asset');
// Display trend in red/blue, brightness in green.
//展示变化趋势,分别用'scale', 'offset', 'scale'三个波段来进行颜色区分
Map.setCenter(30, 45, 4);
Map.addLayer(fit,
         {min: 0, max: [0.18, 20, -0.18], bands: ['scale', 'offset', 'scale']},
         'stable lights trend');


这是分析的第一张影像结果图


再来看看咱们大中国的变化:

 

 



相关文章
|
数据可视化 定位技术 Sentinel
如何用Google Earth Engine快速、大量下载遥感影像数据?
【2月更文挑战第9天】本文介绍在谷歌地球引擎(Google Earth Engine,GEE)中,批量下载指定时间范围、空间范围的遥感影像数据(包括Landsat、Sentinel等)的方法~
5205 1
如何用Google Earth Engine快速、大量下载遥感影像数据?
|
机器学习/深度学习 算法 数据可视化
基于Google Earth Engine云平台构建的多源遥感数据森林地上生物量AGB估算模型含生物量模型应用APP
基于Google Earth Engine云平台构建的多源遥感数据森林地上生物量AGB估算模型含生物量模型应用APP
650 0
|
存储 编解码 数据可视化
Google Earth Engine获取随机抽样点并均匀分布在栅格的不同数值区中
【2月更文挑战第14天】本文介绍在谷歌地球引擎(Google Earth Engine,GEE)中,按照给定的地表分类数据,对每一种不同的地物类型,分别加以全球范围内随机抽样点自动批量选取的方法~
1257 1
Google Earth Engine获取随机抽样点并均匀分布在栅格的不同数值区中
|
API Go 网络架构
GEE Colab——如何从本地/Google云盘/Google Cloud Storage (GCS)上传和下载
GEE Colab——如何从本地/Google云盘/Google Cloud Storage (GCS)上传和下载
889 4
|
机器学习/深度学习 存储 人工智能
GEE Colab——初学者福音快速入门 Google Colab(Colaboratory)
GEE Colab——初学者福音快速入门 Google Colab(Colaboratory)
664 3
|
数据可视化 数据挖掘 数据建模
R语言指数平滑法holt-winters分析谷歌Google Analytics博客用户访问时间序列数据
R语言指数平滑法holt-winters分析谷歌Google Analytics博客用户访问时间序列数据
|
编解码 人工智能 算法
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
310 0
|
编解码 人工智能 数据库
Google Earth Engine(GEE)——全球道路盘查项目全球道路数据库
Google Earth Engine(GEE)——全球道路盘查项目全球道路数据库
398 0
|
编解码
Open Google Earth Engine(OEEL)——matrixUnit(...)中产生常量影像
Open Google Earth Engine(OEEL)——matrixUnit(...)中产生常量影像
247 0
Google Earth Engine(GEE)——导出指定区域的河流和流域范围
Google Earth Engine(GEE)——导出指定区域的河流和流域范围
858 0

热门文章

最新文章

推荐镜像

更多