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');
相关文章
- [Google Guava] 排序: Guava强大的”流畅风格比较器”
- google Guava包的reflection解析
- Google 如何冷却 100 万服务器
- 从Google Quick Draw涂鸦观察不同文化属性
- CSS - 导入Google Web 字体
- Google 2014校招测试赛 Problem C
- Win10上Google Chrome上的ERR_UNSAFE_PORT错误
- 博客园去google广告加载方法
- [Tools] 一键让你的所有设备访问Google、youtube、facebook、twitter、battle.net
- colmap编译过程中出现,无法解析的外部符号错误 “__cdecl google::base::CheckOpMessageBuilder::ForVar1(void)”
- 谷歌验证 (Google Authenticator) 的实现原理是什么?
- 【人工智能 AI】机器学习快速入门教程(Google)
- 【错误记录】Android Studio 编译时 lint 检查报错 ( Error: Google Play requires that apps target API level 29 or )
- 怎样訪问Google