GEE基础学习——Hillshade山阴的计算和显示

简介: GEE基础学习——Hillshade山阴的计算和显示

很多时候我们需要计算山阴主要通过ee.Terrain.hillshade()来实现,具体代码如下:

// Hillshade example.  This is a demonstration of computing
// a hillshade from terrain data and displaying multiple
// layers based on multiple view geometries.  Hillshade
// creation is also provided by ee.Terrain.hillshade().
// Define a function to convert from degrees to radians.
function radians(img) {
  return img.toFloat().multiply(Math.PI).divide(180);
}
// Define a function to compute a hillshade from terrain data
// for the given sun azimuth and elevation.
function hillshade(az, ze, slope, aspect) {
  // Convert angles to radians.
  var azimuth = radians(ee.Image(az));
  var zenith = radians(ee.Image(ze));
  // Note that methods on images are needed to do the computation.
  // i.e. JavaScript operators (e.g. +, -, /, *) do not work on images.
  // The following implements:
  // Hillshade = cos(Azimuth - Aspect) * sin(Slope) * sin(Zenith) +
  //     cos(Zenith) * cos(Slope)
  return azimuth.subtract(aspect).cos()
    .multiply(slope.sin())
    .multiply(zenith.sin())
    .add(
      zenith.cos().multiply(slope.cos()));
}
// Compute terrain meaasures from the SRTM DEM.
var terrain = ee.Algorithms.Terrain(ee.Image('CGIAR/SRTM90_V4'));
var slope = radians(terrain.select('slope'));
var aspect = radians(terrain.select('aspect'));
// For loops are needed for control-flow operations on client-side
// operations.  Here Map.addLayer() is a client operation that needs
// to be performed in a for loop.  In general, avoid for loops
// for any server-side operation.
Map.setCenter(-121.767, 46.852, 11);
for (var i = 0; i < 360; i += 60) {
  Map.addLayer(hillshade(i, 60, slope, aspect), {}, i + ' deg');
}


这个代码的具体思路是首先,及建立一个函数,完成有角度向弧度的转换!


其次就是定义一个新的函数,来计算太阳方位角和高程并通过返回值计算 Hillshade = cos(Azimuth - Aspect) * sin(Slope) * sin(Zenith) +cos(Zenith) * cos(Slope),另外需要注意,我们算数的(+, -, /, *)是不能执行的,因为这里没有用到image.expression进行,也没有合适的波段去进行选择,所以要用英文字母的加减乘除。


剩余的地方基本上就是通过影像分别计算slope和aspect然后进行函数的hillshade的函数计算。


最后进行图像的中心位置显示。

此外本程序还设置了一个循环,也就是每隔60度进行一个方向的展示:



相关文章
|
2月前
GEE——Google dynamic world中在影像导出过程中无法完全导出较大面积影像的解决方案(投影的转换)EPSG:32630和EPSG:4326的区别
GEE——Google dynamic world中在影像导出过程中无法完全导出较大面积影像的解决方案(投影的转换)EPSG:32630和EPSG:4326的区别
39 0
|
25天前
|
机器学习/深度学习 数据可视化 PyTorch
基于TorchViz详解计算图(附代码)
基于TorchViz详解计算图(附代码)
37 0
|
2月前
|
人工智能 数据可视化 算法
AI Earth ——开发者模式案例3:典型植被指数计算及区域统计
AI Earth ——开发者模式案例3:典型植被指数计算及区域统计
43 1
|
2月前
Google Earth Engine(GEE)——如何获取指定时间范围的影像值并进行图表展示(指定天数范围内的时序图)
Google Earth Engine(GEE)——如何获取指定时间范围的影像值并进行图表展示(指定天数范围内的时序图)
50 0
|
9月前
|
算法
MIKE 21 教程 1.4 网格搭建界面介绍之高程数据输入与网格导出 (Mesh Generator 工具)
MIKE 21 教程 1.4 网格搭建界面介绍之高程数据输入与网格导出 (Mesh Generator 工具)
|
11月前
|
数据可视化 数据挖掘 Python
跟着Molecular Plant学作图:R语言circlize包画圈图展示基因组的一些特征补充添加图例
跟着Molecular Plant学作图:R语言circlize包画圈图展示基因组的一些特征补充添加图例
|
12月前
|
JSON 定位技术 数据格式
基于GEE的制作全球任意地方时间序列数据动画的方法
基于GEE的制作全球任意地方时间序列数据动画的方法
116 0
|
编解码 Python
python 如何绘制全球风场(以2020年月均数据为例)
python 如何绘制全球风场(以2020年月均数据为例)
python 如何绘制全球风场(以2020年月均数据为例)
python--循环绘制ERA5风场的空间分布图
使用python封装绘图函数循环绘制ERA5风场资料的空间分布图
python--循环绘制ERA5风场的空间分布图
|
编解码 Python
python 实现不同分辨率的海洋气象数据,线性插值成统一的分辨率(以nc文件为例)
最近,在处理SST以及OLR数据时,需要将两组不同的分辨率的数据插值统一分辨率。 其中,SST的水平网格分辨率为1°×1°,OLR的水平网格分辨率为2.5°×2.5°。 我需要将SST的数据插值为2.5°×2.5°分辨率。
python 实现不同分辨率的海洋气象数据,线性插值成统一的分辨率(以nc文件为例)