美文网首页GEE案例
GEE计算山体阴影

GEE计算山体阴影

作者: 赤豆冰棍 | 来源:发表于2019-01-03 03:17 被阅读0次

使用高程数据来计算山体阴影

主要功能

使用高程数据来计算不同角度的山体阴影,并且在map中添加为多个图层展示。

代码

// 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');
}

步骤分析

  1. 定义函数radians(img)实现角度弧度转换
  2. 定义函数hillshade(az, ze, slope, aspect)来计算山体阴影
  3. 创建ee对象,通过ee.Alogrithms.Terrain来计算坡度坡向等地形度量指标
  4. ee对象特定图层提取
  5. 地图对象设置显示中心,缩放等级
  6. 按照角度循环计算山体阴影,添加计算的山体阴影图层,设置显示参数

主要方法

  1. img.toFloat()
    Casts the input value to a 32-bit float.
    Arguments:
    this:value (Image):
    The image to which the operation is applied.
    Returns: Image

将输入影像投影为32bit浮点型。
本例中,转换为浮点型之后,使用了Math.PI和除法divide()实现角度弧度转换函数radians()

  1. 山体阴影计算
    hillshade(az, ze, slope, aspect)
  • 方位角计算az
    将输入的方位角由角度转化为弧度值

  • 高度角计算ze
    将输入的高度角由角度转化为弧度值

  • 山体阴影计算
    Hillshade = cos(Azimuth - Aspect) * sin(Slope) * sin(Zenith) + cos(Zenith) * cos(Slope)

  1. 按照60°为步长,计算从0到360度的不同方位角的山体阴影
  • for 循环实现对i的计算山体阴影时输入方位角的控制
  • addLayer添加图层,使用i+'deg'来对图层进行命名

相关文章

  • GEE计算山体阴影

    使用高程数据来计算山体阴影 主要功能 使用高程数据来计算不同角度的山体阴影,并且在map中添加为多个图层展示。 代...

  • 表面分析 山体阴影

    山体阴影工具通过为栅格中每个像元值确定照明度,来获取表面的假定照明度。通过设置假定光源的位置和计算与相邻像元相关的...

  • GEE学习笔记 一

    初识GEE GEE简介GEE应用范围GEE优缺点GEE初识 1.GEE是什么? GEE(全称Google Eart...

  • GEE学习笔记 零

    GEE初识 GEE示例以及学习资源介绍 GEE工作台介绍 GEE资源查找 GEE资源上传 GEE资源导出 GEE控...

  • 喜欢少女时代的第六年

    一首Gee火遍大江南北,随处可以听到gee gee gee gee baby baby,那时还不知道自己会以后会...

  • PAPA帮:30岁的她有钱有颜,收藏的爱马仕可以买套房

    说起韩流,相信不少90后的青春回忆里便有唱着"Gee Gee Gee Gee Baby baby baby ”的少...

  • GEE云量计算

    简单云量估计 主要功能 从数据集中选择云量最小的像素,输出展示 代码 步骤分析 创建LC8波段顺序名称列表 定义函...

  • GEE数据集距离计算

    标记特定像素 主要功能 标记大于1000m的像素点,标记等于1000m的像素点 代码 步骤分析 创建ee对象,使用...

  • 贝哥哥21天拖延症88计划第3期第3天

    gee1 gee(SURPRISE)/dʒiː/ exclamationMAINLY US INFORMAL an...

  • GEE归一化指数计算

    归一化指数计算 主要功能 计算指定数据集指定两个波段的归一化指数 代码 步骤分析 创建ee影像对象,通过影像数据集...

网友评论

    本文标题:GEE计算山体阴影

    本文链接:https://www.haomeiwen.com/subject/ityxrqtx.html