Google Earth Engine(GEE)——argument ‘input‘: Invalid type. Expected type: Image<unknown bands>错误

简介: Google Earth Engine(GEE)——argument ‘input‘: Invalid type. Expected type: Image<unknown bands>错误

 

加载影像出现错误:

lope: Layer error: Terrain.slope, argument 'input': Invalid type. Expected type: Image<unknown bands>. Actual type: ImageCollection.


Aspect: Layer error: Terrain.aspect, argument 'input': Invalid type. Expected type: Image<unknown bands>. Actual type: ImageCollection.

错误代码:

var poi = 
    /* color: #d63000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.MultiPolygon(
        [[[[175.15998918717003, -82.43120366717352],
           [175.15998918717003, -82.45432179439132],
           [175.15998918717003, -82.45432179439132],
           [175.15998918717003, -82.43120366717352]]],
         [[[-171.83219831282995, -78.7073936066519],
           [-171.83219831282995, -82.83675780045455],
           [-122.08610456282995, -82.83675780045455],
           [-122.08610456282995, -78.7073936066519]]]], null, false);
Map.centerObject(poi, 6)
var esa = ee.ImageCollection("COPERNICUS/DEM/GLO30")
var elevation = esa.select('DEM');
var elevationVis = {
  min: 0,
  max: 2500,
  palette: ['000096','0064ff', '00b4ff', '33db80', '9beb4a',
  'ffeb00', 'ffb300', 'ff6400', 'eb1e00', 'af0000']
};
Map.addLayer(elevation, elevationVis, 'Elevation Copernicus');
//without converting to a single image
// ERROR
// Calculate slope. Units are degrees, range is [0,90).
var slope = ee.Terrain.slope(elevation);
// Calculate aspect. Units are degrees where 0=N, 90=E, 180=S, 270=W.
var aspect = ee.Terrain.aspect(elevation);
// Display slope and aspect layers on the map.
Map.addLayer(slope, {min: 0, max: 89.99}, 'Slope');
Map.addLayer(aspect, {min: 0, max: 359.99}, 'Aspect');

这里需要选择输入的对象是一个波段,而不是影像集合,所以我们加载影像不能进行多波段加载,只能进行单景影像的加载,这里我们的错误就是从这个方面下手。这里的问题是我们需要裁剪影像,否则无法获取单波段的slope和aspect,因为我们无法对影像集合进行坡度和坡向操作。看下面函数就知道了

所需要的函数:

ee.Terrain.slope(input)

Calculates slope in degrees from a terrain DEM.

The local gradient is computed using the 4-connected neighbors of each pixel, so missing values will occur around the edges of an image.

Arguments:

input (Image):

An elevation image, in meters.

Returns: Image

ee.Terrain.aspect(input)

Calculates aspect in degrees from a terrain DEM.

The local gradient is computed using the 4-connected neighbors of each pixel, so missing values will occur around the edges of an image.

Arguments:

input (Image):

An elevation image, in meters.

Returns: Image

 

Map.addLayer(eeObject, visParams, name, shown, opacity)

Adds a given EE object to the map as a layer.

Returns the new map layer.

Arguments:

eeObject (Collection|Feature|Image|RawMapId):

The object to add to the map.

visParams (FeatureVisualizationParameters|ImageVisualizationParameters, optional):

The visualization parameters. For Images and ImageCollection, see ee.data.getMapId for valid parameters. For Features and FeatureCollections, the only supported key is "color", as a CSS 3.0 color string or a hex string in "RRGGBB" format. Ignored when eeObject is a map ID.

name (String, optional):

The name of the layer. Defaults to "Layer N".

shown (Boolean, optional):

A flag indicating whether the layer should be on by default.

opacity (Number, optional):

The layer's opacity represented as a number between 0 and 1. Defaults to 1.

Returns: ui.Map.Layer

修改后的代码:

var poi = 
    /* color: #d63000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      },
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.MultiPolygon(
        [[[[175.15998918717003, -82.43120366717352],
           [175.15998918717003, -82.45432179439132],
           [175.15998918717003, -82.45432179439132],
           [175.15998918717003, -82.43120366717352]]],
         [[[-171.83219831282995, -78.7073936066519],
           [-171.83219831282995, -82.83675780045455],
           [-122.08610456282995, -82.83675780045455],
           [-122.08610456282995, -78.7073936066519]]]], null, false);
Map.centerObject(poi, 6)
var esa = ee.ImageCollection("COPERNICUS/DEM/GLO30").filterBounds(poi).mosaic().clip(poi)
var elevation = esa.select('DEM');
print("elevation ",elevation )
var elevationVis = {
  min: 0,
  max: 2500,
  palette: ['000096','0064ff', '00b4ff', '33db80', '9beb4a',
  'ffeb00', 'ffb300', 'ff6400', 'eb1e00', 'af0000']
};
Map.addLayer(elevation, elevationVis, 'Elevation Copernicus');
//without converting to a single image
// ERROR
// Calculate slope. Units are degrees, range is [0,90).
var slope = ee.Terrain.slope(elevation);
print(slope)
// Calculate aspect. Units are degrees where 0=N, 90=E, 180=S, 270=W.
var aspect = ee.Terrain.aspect(elevation);
// Display slope and aspect layers on the map.
Map.addLayer(slope, {min: 0, max: 89.99}, 'Slope');
Map.addLayer(aspect, {min: 0, max: 359.99}, 'Aspect');

 

相关文章
|
6月前
|
数据可视化 定位技术 Sentinel
如何用Google Earth Engine快速、大量下载遥感影像数据?
【2月更文挑战第9天】本文介绍在谷歌地球引擎(Google Earth Engine,GEE)中,批量下载指定时间范围、空间范围的遥感影像数据(包括Landsat、Sentinel等)的方法~
2475 1
如何用Google Earth Engine快速、大量下载遥感影像数据?
|
6月前
|
编解码 人工智能 算法
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
88 0
|
6月前
|
机器学习/深度学习 算法 数据可视化
基于Google Earth Engine云平台构建的多源遥感数据森林地上生物量AGB估算模型含生物量模型应用APP
基于Google Earth Engine云平台构建的多源遥感数据森林地上生物量AGB估算模型含生物量模型应用APP
222 0
|
6月前
GEE——Google dynamic world中在影像导出过程中无法完全导出较大面积影像的解决方案(投影的转换)EPSG:32630和EPSG:4326的区别
GEE——Google dynamic world中在影像导出过程中无法完全导出较大面积影像的解决方案(投影的转换)EPSG:32630和EPSG:4326的区别
123 0
|
6月前
|
API Go 网络架构
GEE Colab——如何从本地/Google云盘/Google Cloud Storage (GCS)上传和下载
GEE Colab——如何从本地/Google云盘/Google Cloud Storage (GCS)上传和下载
332 4
|
6月前
|
机器学习/深度学习 存储 人工智能
GEE Colab——初学者福音快速入门 Google Colab(Colaboratory)
GEE Colab——初学者福音快速入门 Google Colab(Colaboratory)
238 3
|
6月前
|
数据处理
Google Earth Engine(GEE)——sentinel-1数据处理过程中出现错误Dictionary does not contain key: bucketMeans
Google Earth Engine(GEE)——sentinel-1数据处理过程中出现错误Dictionary does not contain key: bucketMeans
110 0
|
6月前
|
数据采集 编解码 人工智能
Google Earth Engine(GEE)——全球每日近地表空气温度(2003-2020年)
Google Earth Engine(GEE)——全球每日近地表空气温度(2003-2020年)
220 0
|
6月前
|
编解码 人工智能 数据库
Google Earth Engine(GEE)——全球道路盘查项目全球道路数据库
Google Earth Engine(GEE)——全球道路盘查项目全球道路数据库
143 0
|
6月前
|
编解码
Open Google Earth Engine(OEEL)——matrixUnit(...)中产生常量影像
Open Google Earth Engine(OEEL)——matrixUnit(...)中产生常量影像
76 0

热门文章

最新文章