Google earth engine(GEE)绘制沿山脉断面的海拔和温度(双轴坐标显示)

该博客展示了如何使用Landsat8和DEM数据来分析一条特定直线上的海拔与温度变化。通过对2013-2014年夏季和冬季的L8 TOA影像进行筛选、波段处理和平均值计算,得到温度数据。同时,结合地形数据,绘制了从旧金山到里诺的横断面图,展示海拔和季节性温度的关系。通过UI图表显示了沿直线的距离与温度、海拔的对应关系。
摘要由CSDN通过智能技术生成

这次的案例是通过绘制一条直线,确定沿着这条直线的海拔和随着海拔的温度变化情况,用到的Landsat8数据和DEM数据。时间线主要是2013-2014年的夏天和冬天

温度采用的是L8的第十波段减去273.5得到的设置的时间是根据系统默认时间,获取影像的时间。

 

distance(right, maxErrorproj)

Returns the minimum distance between the geometries of two features.

返回两个要素的几何之间的最小距离。

Arguments:

this:left (Element):

The feature containing the geometry used as the left operand of the operation.

right (Element):

The feature containing the geometry used as the right operand of the operation.

maxError (ErrorMargin, default: null):

The maximum amount of error tolerated when performing any necessary reprojection.

执行任何必要的重新投影时允许的最大错误量。

proj (Projection, default: null):

The projection in which to perform the operation. If not specified, the operation will be performed in a spherical coordinate system, and linear distances will be in meters on the sphere.

Returns: Float

//输入你的起点和重点的坐标,并且连接成线
var reno = [-119.821944, 39.527222];
var sf = [-122.416667, 37.783333];
var transect = ee.Geometry.LineString([reno, sf]);

// 选择影像按照你的线进行边界筛选,并且选出温度波段
var landsat8Toa = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
var temperature = landsat8Toa.filterBounds(transect)
    .select(['B10'], ['temp'])
    .map(function(image) {
      // 温度值转化为摄氏度
      return image.subtract(273.15)
          .set('system:time_start', image.get('system:time_start'));
    });

// 波段平均值计算和日期筛选; 并且合成单一波段影像
var summer = temperature.filterDate('2014-06-21', '2014-09-23')
    .reduce(ee.Reducer.mean())
    .select([0], ['summer']);在0这个位置放入
var winter = temperature.filterDate('2013-12-21', '2014-03-20')
    .reduce(ee.Reducer.mean())
    .select([0], ['winter']);
//选择DEM影像
var elevation = ee.Image('USGS/NED');  
//将点放入矢量集合当中
var startingPoint = ee.FeatureCollection(ee.Geometry.Point(sf));
//容许的间隔误差
var distance = startingPoint.distance(500000);
//将三个值分别加入一个影像形成3个波段
var image = distance.addBands(elevation).addBands(winter).addBands(summer);

// 沿着抛面线提前三个值并且转化为数组提前将数据,采样的间隔是1000
var array = image.reduceRegion(ee.Reducer.toList(), transect, 1000)
                 .toArray(image.bandNames());

//沿横断面按点与起点的距离对点进行排序。
//先切片再排序这是X轴的
var distances = array.slice(0, 0, 1);
array = array.sort(distances);

//先切片再排序这是Y轴的
var elevationAndTemp = array.slice(0, 1);  // For the Y axis.
// 投影距离切片以创建 x 轴值的一维数组。
var distance = array.slice(0, 0, 1).project([1]);

// 画图ui.Chart.array.values(X轴数组,生成一维向量系列所沿的轴,沿图表 x 轴的刻度标签)
var chart = ui.Chart.array.values(elevationAndTemp, 1, distance)
    .setChartType('LineChart')
    .setSeriesNames(['Elevation', 'Winter 2014', 'Summer 2014'])
    .setOptions({
      title: 'Elevation and temperatures along SF-to-Reno transect',
      vAxes: {//分别色湖之Y轴的标题和颜色
        0: {
          title: 'Average seasonal temperature (Celsius)'
        },
        1: {
          title: 'Elevation (meters)',
          baselineColor: 'transparent'
        }
      },
      hAxis: {//设置横轴的标题
        title: 'Distance from SF (m)'
      },
      interpolateNulls: true,
      pointSize: 0,
      lineWidth: 1,
      // Our chart has two Y axes: one for temperature and one for elevation.
      // The Visualization API allows us to assign each series to a specific
      // Y axis, which we do here:
      series: {//谢列的三个位置,一个横轴两个数周
        0: {targetAxisIndex: 1},
        1: {targetAxisIndex: 0},
        2: {targetAxisIndex: 0}
      }
    });

print(chart);
Map.setCenter(-121, 38.5, 7);
Map.addLayer(elevation, {min: 4000, max: 0});
Map.addLayer(transect, {color: 'FF0000'});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

此星光明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值